introduced Projectable interface

This commit is contained in:
Timo Westkämper 2009-03-27 13:13:36 +00:00
parent c7af7e1173
commit 7dc0433e36
2 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,46 @@
package com.mysema.query;
import java.util.Iterator;
import java.util.List;
import com.mysema.query.grammar.types.Expr;
/**
* Projectable provides
*
* @author tiwe
* @version $Id$
*/
public interface Projectable {
/**
* return the amount of matched rows
*/
long count();
/**
* iterate over the results with the given projection
*/
Iterator<Object[]> iterate(Expr<?> e1, Expr<?> e2, Expr<?>... rest);
/**
* iterate over the results with the given projection
*/
<RT> Iterator<RT> iterate(Expr<RT> projection);
/**
* list the results with the given projection
*/
List<Object[]> list(Expr<?> e1, Expr<?> e2, Expr<?>... rest);
/**
* list the results with the given projection
*/
<RT> List<RT> list(Expr<RT> projection);
/**
* return a unique result for the given projection or null for an empty result
*/
<RT> RT uniqueResult(Expr<RT> expr);
}

View File

@ -0,0 +1,46 @@
package com.mysema.query;
import java.util.Iterator;
import java.util.List;
import com.mysema.query.grammar.types.Expr;
/**
* ProjectableAdapter provides
*
* @author tiwe
* @version $Id$
*/
public abstract class ProjectableAdapter implements Projectable{
private Projectable projectable;
public ProjectableAdapter(Projectable projectable){
this.projectable = projectable;
}
public long count() {
return projectable.count();
}
public Iterator<Object[]> iterate(Expr<?> e1, Expr<?> e2, Expr<?>... rest) {
return projectable.iterate(e1, e2, rest);
}
public <RT> Iterator<RT> iterate(Expr<RT> projection) {
return projectable.iterate(projection);
}
public List<Object[]> list(Expr<?> e1, Expr<?> e2, Expr<?>... rest) {
return projectable.list(e1, e2, rest);
}
public <RT> List<RT> list(Expr<RT> projection) {
return projectable.list(projection);
}
public <RT> RT uniqueResult(Expr<RT> expr) {
return projectable.uniqueResult(expr);
}
}