mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-21 21:14:12 +08:00
refactored count and constructor to querydsl-hibernate
made HqlSerializer use String.format templates instead of operator string + operator position
This commit is contained in:
parent
0b7104da82
commit
032b0d8593
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package com.mysema.query;
|
||||
|
||||
import com.mysema.query.grammar.Types.ExprForBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprForEntity;
|
||||
import com.mysema.query.grammar.Types.ExprBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprEntity;
|
||||
|
||||
/**
|
||||
* ExtQuery externds the Query interface to provide innerJoin, leftJoin and with methods
|
||||
@ -15,8 +15,8 @@ import com.mysema.query.grammar.Types.ExprForEntity;
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ExtQuery<A extends ExtQuery<A>> extends Query<A> {
|
||||
A innerJoin(ExprForEntity<?> object);
|
||||
A join(ExprForEntity<?> object);
|
||||
A leftJoin(ExprForEntity<?> object);
|
||||
A with(ExprForBoolean... objects);
|
||||
A innerJoin(ExprEntity<?> o);
|
||||
A join(ExprEntity<?> o);
|
||||
A leftJoin(ExprEntity<?> o);
|
||||
A with(ExprBoolean... o);
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package com.mysema.query;
|
||||
|
||||
import com.mysema.query.grammar.Types.ExprForBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprForEntity;
|
||||
import com.mysema.query.grammar.Types.ExprBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprEntity;
|
||||
|
||||
/**
|
||||
* ExtQueryBased provides a basic implementation of the ExtQuery interface
|
||||
@ -17,24 +17,24 @@ import com.mysema.query.grammar.Types.ExprForEntity;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ExtQueryBase<A extends ExtQueryBase<A>> extends QueryBase<A> implements ExtQuery<A> {
|
||||
|
||||
public A innerJoin(ExprForEntity<?> object) {
|
||||
joins.add(new JoinExpression(JoinType.IJ,object));
|
||||
public A innerJoin(ExprEntity<?> o) {
|
||||
joins.add(new JoinExpression(JoinType.IJ,o));
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A join(ExprForEntity<?> object) {
|
||||
joins.add(new JoinExpression(JoinType.J,object));
|
||||
public A join(ExprEntity<?> o) {
|
||||
joins.add(new JoinExpression(JoinType.J,o));
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A leftJoin(ExprForEntity<?> object) {
|
||||
joins.add(new JoinExpression(JoinType.LJ,object));
|
||||
public A leftJoin(ExprEntity<?> o) {
|
||||
joins.add(new JoinExpression(JoinType.LJ,o));
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A with(ExprForBoolean... objects) {
|
||||
public A with(ExprBoolean... o) {
|
||||
if (!joins.isEmpty()){
|
||||
joins.get(joins.size()-1).conditions = objects;
|
||||
joins.get(joins.size()-1).conditions = o;
|
||||
}
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package com.mysema.query;
|
||||
|
||||
import com.mysema.query.grammar.Types.ExprForBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprForEntity;
|
||||
import com.mysema.query.grammar.Types.ExprBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprEntity;
|
||||
import com.mysema.query.grammar.Types.Expr;
|
||||
import com.mysema.query.grammar.Types.OrderSpecifier;
|
||||
|
||||
@ -17,10 +17,10 @@ import com.mysema.query.grammar.Types.OrderSpecifier;
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface Query<A extends Query<A>>{
|
||||
A select(Expr<?>... objects);
|
||||
A from(ExprForEntity<?>... objects);
|
||||
A where(ExprForBoolean... objects);
|
||||
A groupBy(Expr<?>... objects);
|
||||
A having(ExprForBoolean... objects);
|
||||
A orderBy(OrderSpecifier<?>... objects);
|
||||
A select(Expr<?>... o);
|
||||
A from(ExprEntity<?>... o);
|
||||
A where(ExprBoolean... o);
|
||||
A groupBy(Expr<?>... o);
|
||||
A having(ExprBoolean... o);
|
||||
A orderBy(OrderSpecifier<?>... o);
|
||||
}
|
||||
@ -8,8 +8,8 @@ package com.mysema.query;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.query.grammar.Types.ExprForBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprForEntity;
|
||||
import com.mysema.query.grammar.Types.ExprBoolean;
|
||||
import com.mysema.query.grammar.Types.ExprEntity;
|
||||
import com.mysema.query.grammar.Types.Expr;
|
||||
import com.mysema.query.grammar.Types.OrderSpecifier;
|
||||
/**
|
||||
@ -26,20 +26,20 @@ public class QueryBase<A extends QueryBase<A>> implements Query<A> {
|
||||
|
||||
public class JoinExpression{
|
||||
public final JoinType type;
|
||||
public final ExprForEntity<?> target;
|
||||
JoinExpression(JoinType type, ExprForEntity<?> target){
|
||||
public final ExprEntity<?> target;
|
||||
JoinExpression(JoinType type, ExprEntity<?> target){
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
}
|
||||
public ExprForBoolean[] conditions;
|
||||
public ExprBoolean[] conditions;
|
||||
}
|
||||
|
||||
protected List<JoinExpression> joins = new ArrayList<JoinExpression>();
|
||||
protected Expr<?>[] groupBy;
|
||||
protected ExprForBoolean[] having;
|
||||
protected ExprBoolean[] having;
|
||||
protected OrderSpecifier<?>[] orderBy;
|
||||
protected Expr<?>[] select;
|
||||
protected ExprForBoolean[] where;
|
||||
protected ExprBoolean[] where;
|
||||
|
||||
protected void clear(){
|
||||
joins.clear();
|
||||
@ -50,36 +50,36 @@ public class QueryBase<A extends QueryBase<A>> implements Query<A> {
|
||||
where = null;
|
||||
}
|
||||
|
||||
public A from(ExprForEntity<?>... objects) {
|
||||
for (ExprForEntity<?> expr : objects){
|
||||
public A from(ExprEntity<?>... o) {
|
||||
for (ExprEntity<?> expr : o){
|
||||
joins.add(new JoinExpression(JoinType.DEFAULT,expr));
|
||||
}
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A groupBy(Expr<?>... objects) {
|
||||
groupBy = objects;
|
||||
public A groupBy(Expr<?>... o) {
|
||||
groupBy = o;
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A having(ExprForBoolean... objects) {
|
||||
having = objects;
|
||||
public A having(ExprBoolean... o) {
|
||||
having = o;
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
|
||||
public A orderBy(OrderSpecifier<?>... objects) {
|
||||
orderBy = objects;
|
||||
public A orderBy(OrderSpecifier<?>... o) {
|
||||
orderBy = o;
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A select(Expr<?>... objects) {
|
||||
select = objects;
|
||||
public A select(Expr<?>... o) {
|
||||
select = o;
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A where(ExprForBoolean... objects) {
|
||||
where = objects;
|
||||
public A where(ExprBoolean... o) {
|
||||
where = o;
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
|
||||
@ -5,8 +5,10 @@
|
||||
*/
|
||||
package com.mysema.query.grammar;
|
||||
|
||||
import com.mysema.query.grammar.Types.*;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.mysema.query.grammar.Ops.*;
|
||||
import com.mysema.query.grammar.Types.*;
|
||||
|
||||
/**
|
||||
* Grammar provides the factory methods for the fluent grammar
|
||||
@ -16,7 +18,7 @@ import com.mysema.query.grammar.Ops.*;
|
||||
*/
|
||||
public class Grammar {
|
||||
|
||||
static <L, R> ExprForBoolean _binOp(Op<Boolean> operator, Expr<L> left,
|
||||
static <L, R> ExprBoolean _binOp(Op<Boolean> operator, Expr<L> left,
|
||||
Expr<R> right) {
|
||||
OperationBinaryBoolean<L, R> op = new OperationBinaryBoolean<L, R>();
|
||||
op.operator = operator;
|
||||
@ -57,7 +59,7 @@ public class Grammar {
|
||||
return os;
|
||||
}
|
||||
|
||||
static <F, S, T> ExprForBoolean _terOp(Op<Boolean> type, Expr<F> fst,
|
||||
static <F, S, T> ExprBoolean _terOp(Op<Boolean> type, Expr<F> fst,
|
||||
Expr<S> snd, Expr<T> trd) {
|
||||
OperationTertiaryBoolean<F, S, T> op = new OperationTertiaryBoolean<F, S, T>();
|
||||
op.operator = type;
|
||||
@ -77,7 +79,7 @@ public class Grammar {
|
||||
return op;
|
||||
}
|
||||
|
||||
static <A> ExprForBoolean _unOp(Op<Boolean> type, Expr<A> left) {
|
||||
static <A> ExprBoolean _unOp(Op<Boolean> type, Expr<A> left) {
|
||||
OperationUnaryBoolean<A> op = new OperationUnaryBoolean<A>();
|
||||
op.operator = type;
|
||||
op.left = left;
|
||||
@ -91,15 +93,15 @@ public class Grammar {
|
||||
return op;
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> add(Expr<A> left, A right) {
|
||||
public static <A extends Number> ExprNoEntity<A> add(Expr<A> left, A right) {
|
||||
return _binOp(OpNumber.ADD, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> add(Expr<A> left, Expr<A> right) {
|
||||
public static <A extends Number> ExprNoEntity<A> add(Expr<A> left, Expr<A> right) {
|
||||
return _binOp(OpNumber.ADD, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean after(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean after(Expr<A> left,
|
||||
A right) {
|
||||
// NOTE : signature is for Comparables to support other than Java's date
|
||||
// types
|
||||
@ -107,7 +109,7 @@ public class Grammar {
|
||||
return _binOp(OpDate.AFTER, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean after(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean after(Expr<A> left,
|
||||
Expr<A> right) {
|
||||
// NOTE : signature is for Comparables to support other than Java's date
|
||||
// types
|
||||
@ -115,28 +117,28 @@ public class Grammar {
|
||||
return _binOp(OpDate.AFTER, left, right);
|
||||
}
|
||||
|
||||
public static ExprForBoolean and(ExprForBoolean left, ExprForBoolean right) {
|
||||
public static ExprBoolean and(ExprBoolean left, ExprBoolean right) {
|
||||
return _binOp(OpBoolean.AND, left, right);
|
||||
}
|
||||
|
||||
public static <D> AliasForCollection<D> as(PathForEntityCollection<D> from, PathForEntity<D> to) {
|
||||
return new AliasForCollection<D>(from, to);
|
||||
}
|
||||
|
||||
public static <D> AliasForEntity<D> as(PathForEntity<D> from, PathForEntity<D> to) {
|
||||
return new AliasForEntity<D>(from, to);
|
||||
}
|
||||
|
||||
public static <D> AliasForNoEntity<D> as(ExprForNoEntity<D> from, String to) {
|
||||
public static <D> AliasNoEntity<D> as(ExprNoEntity<D> from, String to) {
|
||||
// NOTE : maybe this needs to be possible for all expressions
|
||||
return new AliasForNoEntity<D>(from, to);
|
||||
return new AliasNoEntity<D>(from, to);
|
||||
}
|
||||
|
||||
public static <D> AliasEntity<D> as(PathEntity<D> from, PathEntity<D> to) {
|
||||
return new AliasEntity<D>(from, to);
|
||||
}
|
||||
|
||||
public static <D> AliasCollection<D> as(PathEntityCollection<D> from, PathEntity<D> to) {
|
||||
return new AliasCollection<D>(from, to);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> OrderSpecifier<A> asc(Expr<A> target) {
|
||||
return _orderAsc(target);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean before(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean before(Expr<A> left,
|
||||
A right) {
|
||||
// NOTE : signature is for Comparables to support other than Java's date
|
||||
// types
|
||||
@ -144,7 +146,7 @@ public class Grammar {
|
||||
return _binOp(OpDate.BEFORE, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean before(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean before(Expr<A> left,
|
||||
Expr<A> right) {
|
||||
// NOTE : signature is for Comparables to support other than Java's date
|
||||
// types
|
||||
@ -152,150 +154,154 @@ public class Grammar {
|
||||
return _binOp(OpDate.BEFORE, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean between(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean between(Expr<A> left,
|
||||
A start, A end) {
|
||||
return _terOp(OpComparable.BETWEEN, left, _const(start), _const(end));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean between(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean between(Expr<A> left,
|
||||
Expr<A> start, Expr<A> end) {
|
||||
return _terOp(OpComparable.BETWEEN, left, start, end);
|
||||
}
|
||||
|
||||
public static ExprForNoEntity<String> concat(Expr<String> left, Expr<String> right) {
|
||||
public static ExprNoEntity<String> concat(Expr<String> left, Expr<String> right) {
|
||||
return _binOp(OpString.CONCAT, left, right);
|
||||
}
|
||||
|
||||
public static ExprForNoEntity<Long> count(){
|
||||
return new CountExpr<Long>();
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> OrderSpecifier<A> desc(
|
||||
Expr<A> target) {
|
||||
return _orderDesc(target);
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> div(Expr<A> left, A right) {
|
||||
public static <A extends Number> ExprNoEntity<A> div(Expr<A> left, A right) {
|
||||
return _binOp(OpNumber.DIV, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> div(Expr<A> left, Expr<A> right) {
|
||||
public static <A extends Number> ExprNoEntity<A> div(Expr<A> left, Expr<A> right) {
|
||||
return _binOp(OpNumber.DIV, left, right);
|
||||
}
|
||||
|
||||
public static <A, B extends A> ExprForBoolean eq(Expr<A> left, B right) {
|
||||
public static <A, B extends A> ExprBoolean eq(Expr<A> left, B right) {
|
||||
return _binOp(Op.EQ, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A, B extends A> ExprForBoolean eq(Expr<A> left, Expr<B> right) {
|
||||
public static <A, B extends A> ExprBoolean eq(Expr<A> left, Expr<B> right) {
|
||||
return _binOp(Op.EQ, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean goe(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean goe(Expr<A> left,
|
||||
A right) {
|
||||
return _binOp(OpNumber.GOE, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean goe(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean goe(Expr<A> left,
|
||||
Expr<A> right) {
|
||||
return _binOp(OpNumber.GOE, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean gt(Expr<A> left, A right) {
|
||||
public static <A extends Comparable<A>> ExprBoolean gt(Expr<A> left, A right) {
|
||||
return _binOp(OpNumber.GT, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean gt(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean gt(Expr<A> left,
|
||||
Expr<A> right) {
|
||||
return _binOp(OpNumber.GT, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean in(Expr<A> left,
|
||||
public static <A> ExprBoolean in(A left, ExprEntity<Collection<A>> right){
|
||||
return _binOp(Op.INELEMENTS, _const(left), right);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprBoolean in(Expr<A> left,
|
||||
A... rest) {
|
||||
return _binOp(Op.IN, left, _const(rest));
|
||||
return _binOp(Op.INARRAY, left, _const(rest));
|
||||
}
|
||||
|
||||
public static <A> ExprBoolean in(ExprEntity<A> left, ExprEntity<Collection<A>> right){
|
||||
return _binOp(Op.INELEMENTS, left, right);
|
||||
}
|
||||
|
||||
public static <A> ExprForBoolean isnotnull(Expr<A> left) {
|
||||
public static <A> ExprBoolean isnotnull(Expr<A> left) {
|
||||
return _unOp(Op.ISNOTNULL, left);
|
||||
}
|
||||
|
||||
public static <A> ExprForBoolean isnull(Expr<A> left) {
|
||||
public static <A> ExprBoolean isnull(Expr<A> left) {
|
||||
return _unOp(Op.ISNULL, left);
|
||||
}
|
||||
|
||||
public static ExprForBoolean like(Expr<String> left, String right) {
|
||||
public static ExprBoolean like(Expr<String> left, String right) {
|
||||
return _binOp(OpString.LIKE, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean loe(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean loe(Expr<A> left,
|
||||
A right) {
|
||||
return _binOp(OpNumber.LOE, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean loe(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean loe(Expr<A> left,
|
||||
Expr<A> right) {
|
||||
return _binOp(OpNumber.LOE, left, right);
|
||||
}
|
||||
|
||||
public static ExprForNoEntity<String> lower(Expr<String> left) {
|
||||
public static ExprNoEntity<String> lower(Expr<String> left) {
|
||||
return _unOp(OpString.LOWER, left);
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean lt(Expr<A> left, A right) {
|
||||
public static <A extends Comparable<A>> ExprBoolean lt(Expr<A> left, A right) {
|
||||
return _binOp(OpNumber.LT, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Comparable<A>> ExprForBoolean lt(Expr<A> left,
|
||||
public static <A extends Comparable<A>> ExprBoolean lt(Expr<A> left,
|
||||
Expr<A> right) {
|
||||
return _binOp(OpNumber.LT, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> mult(Expr<A> left, A right) {
|
||||
public static <A extends Number> ExprNoEntity<A> mult(Expr<A> left, A right) {
|
||||
return _binOp(OpNumber.MULT, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> mult(Expr<A> left, Expr<A> right) {
|
||||
public static <A extends Number> ExprNoEntity<A> mult(Expr<A> left, Expr<A> right) {
|
||||
return _binOp(OpNumber.MULT, left, right);
|
||||
}
|
||||
|
||||
public static <A, B extends A> ExprForBoolean ne(Expr<A> left, B right) {
|
||||
public static <A, B extends A> ExprBoolean ne(Expr<A> left, B right) {
|
||||
return _binOp(Op.NE, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A, B extends A> ExprForBoolean ne(Expr<A> left, Expr<B> right) {
|
||||
public static <A, B extends A> ExprBoolean ne(Expr<A> left, Expr<B> right) {
|
||||
return _binOp(Op.NE, left, right);
|
||||
}
|
||||
|
||||
public static ExprForBoolean not(ExprForBoolean left) {
|
||||
public static ExprBoolean not(ExprBoolean left) {
|
||||
return _unOp(OpBoolean.NOT, left);
|
||||
}
|
||||
|
||||
public static ExprForBoolean or(ExprForBoolean left, ExprForBoolean right) {
|
||||
public static ExprBoolean or(ExprBoolean left, ExprBoolean right) {
|
||||
return _binOp(OpBoolean.OR, left, right);
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> sub(Expr<A> left, A right) {
|
||||
public static <A extends Number> ExprNoEntity<A> sub(Expr<A> left, A right) {
|
||||
return _binOp(OpNumber.SUB, left, _const(right));
|
||||
}
|
||||
|
||||
public static <A extends Number> ExprForNoEntity<A> sub(Expr<A> left, Expr<A> right) {
|
||||
public static <A extends Number> ExprNoEntity<A> sub(Expr<A> left, Expr<A> right) {
|
||||
return _binOp(OpNumber.SUB, left, right);
|
||||
}
|
||||
|
||||
public static ExprForNoEntity<String> substr(Expr<String> left, int start) {
|
||||
public static ExprNoEntity<String> substr(Expr<String> left, int start) {
|
||||
return _binOp(OpString.SUBSTR, left, _const(start));
|
||||
}
|
||||
|
||||
public static ExprForNoEntity<String> substr(Expr<String> left, int start, int offset) {
|
||||
public static ExprNoEntity<String> substr(Expr<String> left, int start, int offset) {
|
||||
return _terOp(OpString.SUBSTR, left, _const(start), _const(offset));
|
||||
}
|
||||
|
||||
public static <A, B extends A> ExprForBoolean typeOf(Expr<A> left,
|
||||
public static <A, B extends A> ExprBoolean typeOf(Expr<A> left,
|
||||
Class<B> right) {
|
||||
return _binOp(Op.ISTYPEOF, left, _const(right));
|
||||
}
|
||||
|
||||
public static ExprForNoEntity<String> upper(Expr<String> left) {
|
||||
public static ExprNoEntity<String> upper(Expr<String> left) {
|
||||
return _unOp(OpString.UPPER, left);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,8 @@ public class Ops {
|
||||
*/
|
||||
public interface Op<RT> {
|
||||
Op<Boolean> EQ = new OpImpl<Boolean>();
|
||||
Op<Boolean> IN = new OpImpl<Boolean>();
|
||||
Op<Boolean> INARRAY = new OpImpl<Boolean>();
|
||||
Op<Boolean> INELEMENTS = new OpImpl<Boolean>();
|
||||
Op<Boolean> ISNOTNULL = new OpImpl<Boolean>();
|
||||
Op<Boolean> ISNULL = new OpImpl<Boolean>();
|
||||
Op<Boolean> ISTYPEOF = new OpImpl<Boolean>();
|
||||
|
||||
@ -18,7 +18,7 @@ import com.mysema.query.grammar.Ops.Op;
|
||||
*/
|
||||
public class Types {
|
||||
|
||||
public abstract static class Alias<D> extends ExprImpl<D>{
|
||||
public abstract static class Alias<D> extends ExprNonFinalImpl<D>{
|
||||
public final Expr<?> from;
|
||||
public final String to;
|
||||
Alias(Expr<?> from, String to) {
|
||||
@ -27,23 +27,23 @@ public class Types {
|
||||
}
|
||||
}
|
||||
|
||||
public static class AliasForCollection<D> extends Alias<D> implements ExprForEntity<D>{
|
||||
AliasForCollection(PathForEntityCollection<D> from, Path<D> to) {
|
||||
public static class AliasCollection<D> extends Alias<D> implements ExprEntity<D>{
|
||||
AliasCollection(PathEntityCollection<D> from, Path<D> to) {
|
||||
super(from,to.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static class AliasForEntity<D> extends Alias<D> implements ExprForEntity<D>{
|
||||
AliasForEntity(PathForEntity<D> from, PathForEntity<D> to) {
|
||||
public static class AliasEntity<D> extends Alias<D> implements ExprEntity<D>{
|
||||
AliasEntity(PathEntity<D> from, PathEntity<D> to) {
|
||||
super(from,to.toString());
|
||||
}
|
||||
AliasForEntity(PathForEntity<D> from, String to) {
|
||||
AliasEntity(PathEntity<D> from, String to) {
|
||||
super(from,to);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AliasForNoEntity<D> extends Alias<D> implements ExprForNoEntity<D>{
|
||||
AliasForNoEntity(Expr<D> from, String to) {
|
||||
public static class AliasNoEntity<D> extends Alias<D> implements ExprNoEntity<D>{
|
||||
AliasNoEntity(Expr<D> from, String to) {
|
||||
super(from,to);
|
||||
}
|
||||
public Expr<D> as(String to) {
|
||||
@ -51,44 +51,44 @@ public class Types {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConstantExpr<D> extends ExprImpl<D>{
|
||||
public static class ConstantExpr<D> extends ExprNonFinalImpl<D>{
|
||||
public D constant;
|
||||
}
|
||||
|
||||
public static class CountExpr<D> extends ExprForNoEntityImpl<D>{
|
||||
// TODO : move to querydsl-hibernate
|
||||
public interface Expr<D> {
|
||||
|
||||
}
|
||||
|
||||
public interface Expr<D> {
|
||||
public <B extends D> ExprForBoolean eq(B right);
|
||||
public <B extends D> ExprForBoolean eq(Expr<B> right);
|
||||
public <B extends D> ExprForBoolean ne(B right);
|
||||
public <B extends D> ExprForBoolean ne(Expr<B> right);
|
||||
public interface ExprNonFinal<D> extends Expr<D> {
|
||||
public <B extends D> ExprBoolean eq(B right);
|
||||
public <B extends D> ExprBoolean eq(Expr<B> right);
|
||||
public <B extends D> ExprBoolean ne(B right);
|
||||
public <B extends D> ExprBoolean ne(Expr<B> right);
|
||||
}
|
||||
|
||||
static abstract class ExprImpl<D> implements Expr<D>{
|
||||
public <B extends D> ExprForBoolean eq(B right){return Grammar.eq(this, right);}
|
||||
public <B extends D> ExprForBoolean eq(Expr<B> right){return Grammar.eq(this, right);}
|
||||
public <B extends D> ExprForBoolean ne(B right){return Grammar.ne(this, right);}
|
||||
public <B extends D> ExprForBoolean ne(Expr<B> right){return Grammar.ne(this, right);}
|
||||
}
|
||||
|
||||
public interface ExprForBoolean extends ExprForNoEntity<Boolean>{ }
|
||||
public interface ExprBoolean extends ExprNoEntity<Boolean>{ }
|
||||
|
||||
/**
|
||||
* Reference to an entity
|
||||
*/
|
||||
public interface ExprForEntity<D> extends Expr<D>{}
|
||||
public interface ExprEntity<D> extends Expr<D>{}
|
||||
|
||||
static abstract class ExprNonFinalImpl<D> implements ExprNonFinal<D>{
|
||||
public <B extends D> ExprBoolean eq(B right){return Grammar.eq(this, right);}
|
||||
public <B extends D> ExprBoolean eq(Expr<B> right){return Grammar.eq(this, right);}
|
||||
public <B extends D> ExprBoolean ne(B right){return Grammar.ne(this, right);}
|
||||
public <B extends D> ExprBoolean ne(Expr<B> right){return Grammar.ne(this, right);}
|
||||
}
|
||||
|
||||
public interface ExprForNoEntity<D> extends Expr<D>{
|
||||
public interface ExprNoEntity<D> extends ExprNonFinal<D>{
|
||||
public Expr<D> as(String to);
|
||||
}
|
||||
|
||||
static abstract class ExprForNoEntityImpl<D> extends ExprImpl<D> implements ExprForNoEntity<D>{
|
||||
public static abstract class ExprNoEntityImpl<D> extends ExprNonFinalImpl<D> implements ExprNoEntity<D>{
|
||||
public Expr<D> as(String to){return Grammar.as(this, to);}
|
||||
}
|
||||
|
||||
public abstract static class Operation<RT> extends ExprForNoEntityImpl<RT> {
|
||||
public abstract static class Operation<RT> extends ExprNoEntityImpl<RT> {
|
||||
public Expr<RT> as(String to) {
|
||||
return Grammar.as(this, to);
|
||||
}
|
||||
@ -104,7 +104,7 @@ public class Types {
|
||||
}
|
||||
|
||||
public static class OperationBinaryBoolean<L,R> extends OperationBinary<Boolean,Boolean,L,R>
|
||||
implements ExprForBoolean {
|
||||
implements ExprBoolean {
|
||||
public Expr<Boolean> as(String to) {
|
||||
return Grammar.as(this, to);
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class Types {
|
||||
}
|
||||
|
||||
public static class OperationTertiaryBoolean<F,S,T> extends OperationTertiary<Boolean,Boolean,F,S,T>
|
||||
implements ExprForBoolean{
|
||||
implements ExprBoolean{
|
||||
}
|
||||
|
||||
public static class OperationUnary<OP,RT extends OP,A> extends Operation<RT>{
|
||||
@ -133,7 +133,7 @@ public class Types {
|
||||
}
|
||||
|
||||
public static class OperationUnaryBoolean<A> extends OperationUnary<Boolean,Boolean,A>
|
||||
implements ExprForBoolean{
|
||||
implements ExprBoolean{
|
||||
}
|
||||
|
||||
public enum Order{ ASC,DESC }
|
||||
@ -143,7 +143,7 @@ public class Types {
|
||||
public Expr<A> target;
|
||||
}
|
||||
|
||||
public abstract static class Path<D> extends ExprImpl<D>{
|
||||
public abstract static class Path<D> extends ExprNonFinalImpl<D>{
|
||||
// path is hidden to not pollute the namespace of the domain types
|
||||
private final String path;
|
||||
public Path(String p) {
|
||||
@ -153,40 +153,40 @@ public class Types {
|
||||
public final String toString(){ return path; }
|
||||
}
|
||||
|
||||
public static class PathForBoolean extends PathForNoEntity<Boolean> implements ExprForBoolean{
|
||||
PathForBoolean(String path) {super(path);}
|
||||
public static class PathBoolean extends PathNoEntity<Boolean> implements ExprBoolean{
|
||||
PathBoolean(String path) {super(path);}
|
||||
}
|
||||
|
||||
public static class PathForEntity<D> extends Path<D> implements ExprForEntity<D>{
|
||||
protected PathForEntity(PathForEntity<?> type, String path) {
|
||||
public static class PathEntity<D> extends Path<D> implements ExprEntity<D>{
|
||||
protected PathEntity(PathEntity<?> type, String path) {
|
||||
super(type+"."+path);
|
||||
}
|
||||
protected PathForEntity(String path) {super(path);}
|
||||
protected PathForBoolean _boolean(String path){
|
||||
return new PathForBoolean(this+"."+path);
|
||||
protected PathEntity(String path) {super(path);}
|
||||
protected PathBoolean _boolean(String path){
|
||||
return new PathBoolean(this+"."+path);
|
||||
}
|
||||
protected <A>PathForEntityCollection<A> _collection(String path,Class<A> type) {
|
||||
return new PathForEntityCollection<A>(this+"."+path);
|
||||
protected <A>PathEntityCollection<A> _collection(String path,Class<A> type) {
|
||||
return new PathEntityCollection<A>(this+"."+path);
|
||||
}
|
||||
protected <A> PathForNoEntity<A> _prop(String path,Class<A> type) {
|
||||
return new PathForNoEntity<A>(this+"."+path);
|
||||
protected <A> PathNoEntity<A> _prop(String path,Class<A> type) {
|
||||
return new PathNoEntity<A>(this+"."+path);
|
||||
}
|
||||
|
||||
public AliasForEntity<D> as(PathForEntity<D> to) {return Grammar.as(this, to);}
|
||||
public AliasEntity<D> as(PathEntity<D> to) {return Grammar.as(this, to);}
|
||||
}
|
||||
|
||||
public static class PathForEntityCollection<D> extends Path<Collection<D>> implements
|
||||
ExprForEntity<Collection<D>>{
|
||||
PathForEntityCollection(String p) {
|
||||
public static class PathEntityCollection<D> extends Path<Collection<D>> implements
|
||||
ExprEntity<Collection<D>>{
|
||||
PathEntityCollection(String p) {
|
||||
super(p);
|
||||
}
|
||||
public AliasForCollection<D> as(PathForEntity<D> to) {
|
||||
public AliasCollection<D> as(PathEntity<D> to) {
|
||||
return Grammar.as(this, to);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PathForNoEntity<D> extends Path<D> implements ExprForNoEntity<D>{
|
||||
public PathForNoEntity(String p) {
|
||||
public static class PathNoEntity<D> extends Path<D> implements ExprNoEntity<D>{
|
||||
public PathNoEntity(String p) {
|
||||
super(p);
|
||||
}
|
||||
public Expr<D> as(String to) {
|
||||
|
||||
@ -22,10 +22,10 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
@Override
|
||||
protected Method create(Class<?> cl) {
|
||||
while (!Types.class.equals(cl.getEnclosingClass())){
|
||||
cl = cl.getSuperclass();
|
||||
}
|
||||
try {
|
||||
if (PathEntity.class.isAssignableFrom(cl)){
|
||||
cl = PathEntity.class;
|
||||
}
|
||||
Method method = null;
|
||||
Class<?> sigClass = Visitor.this.getClass();
|
||||
while (method == null && !sigClass.equals(Visitor.class)){
|
||||
@ -60,16 +60,14 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
protected abstract void visit(Alias<?> expr);
|
||||
|
||||
protected abstract void visit(AliasForNoEntity<?> expr);
|
||||
protected abstract void visit(AliasNoEntity<?> expr);
|
||||
|
||||
protected abstract void visit(AliasForCollection<?> expr);
|
||||
protected abstract void visit(AliasCollection<?> expr);
|
||||
|
||||
protected abstract void visit(AliasForEntity<?> expr);
|
||||
protected abstract void visit(AliasEntity<?> expr);
|
||||
|
||||
protected abstract void visit(ConstantExpr<?> expr);
|
||||
|
||||
protected abstract void visit(CountExpr<?> expr);
|
||||
|
||||
protected abstract void visit(OperationBinary<?,?,?,?> expr);
|
||||
|
||||
protected abstract void visit(OperationBinaryBoolean<?,?> expr);
|
||||
@ -84,12 +82,12 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
protected abstract void visit(Path<?> expr);
|
||||
|
||||
protected abstract void visit(PathForBoolean expr);
|
||||
protected abstract void visit(PathBoolean expr);
|
||||
|
||||
protected abstract void visit(PathForEntityCollection<?> expr);
|
||||
protected abstract void visit(PathEntityCollection<?> expr);
|
||||
|
||||
protected abstract void visit(PathForEntity<?> expr);
|
||||
protected abstract void visit(PathEntity<?> expr);
|
||||
|
||||
protected abstract void visit(PathForNoEntity<?> expr);
|
||||
protected abstract void visit(PathNoEntity<?> expr);
|
||||
|
||||
}
|
||||
|
||||
@ -17,17 +17,17 @@ import com.mysema.query.grammar.Types.*;
|
||||
public abstract class VisitorAdapter<V extends VisitorAdapter<V>> extends Visitor<V>{
|
||||
|
||||
@Override
|
||||
protected void visit(AliasForNoEntity<?> expr) {
|
||||
protected void visit(AliasNoEntity<?> expr) {
|
||||
visit((Alias<?>)expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(AliasForCollection<?> expr){
|
||||
protected void visit(AliasCollection<?> expr){
|
||||
visit((Alias<?>)expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(AliasForEntity<?> expr) {
|
||||
protected void visit(AliasEntity<?> expr) {
|
||||
visit((Alias<?>)expr);
|
||||
}
|
||||
|
||||
@ -37,22 +37,22 @@ public abstract class VisitorAdapter<V extends VisitorAdapter<V>> extends Visito
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(PathForBoolean expr) {
|
||||
protected void visit(PathBoolean expr) {
|
||||
visit((Path<?>)expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(PathForEntityCollection<?> expr){
|
||||
protected void visit(PathEntityCollection<?> expr){
|
||||
visit((Path<?>)expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(PathForEntity<?> expr) {
|
||||
protected void visit(PathEntity<?> expr) {
|
||||
visit((Path<?>)expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(PathForNoEntity<?> expr) {
|
||||
protected void visit(PathNoEntity<?> expr) {
|
||||
visit((Path<?>)expr);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user