mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
made most of Expr methods final
moved in and notIn methods to top level
This commit is contained in:
parent
361154f596
commit
7fb5128dc2
@ -5,6 +5,8 @@
|
||||
*/
|
||||
package com.mysema.query.grammar;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.mysema.query.grammar.Ops.OpNumberAgg;
|
||||
import com.mysema.query.grammar.types.Alias;
|
||||
import com.mysema.query.grammar.types.CollectionType;
|
||||
@ -466,10 +468,24 @@ public class Grammar extends Factory{
|
||||
* @param right
|
||||
* @return
|
||||
*/
|
||||
public static <A> EBoolean in(A left, CollectionType<A> right){
|
||||
public static <A> EBoolean in(A left, CollectionType<? extends A> right){
|
||||
return createBoolean(Ops.IN, createConstant(left), (Expr<?>)right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expr : left in right
|
||||
* OR
|
||||
* right contains left
|
||||
*
|
||||
* @param <A>
|
||||
* @param left
|
||||
* @param right
|
||||
* @return
|
||||
*/
|
||||
public static <A> EBoolean in(Expr<A> left, Collection<? extends A> right){
|
||||
return createBoolean(Ops.IN, left, createConstant(right));
|
||||
}
|
||||
|
||||
/**
|
||||
* Expr : left in rest
|
||||
* OR
|
||||
@ -785,7 +801,7 @@ public class Grammar extends Factory{
|
||||
* @param rest
|
||||
* @return
|
||||
*/
|
||||
public static <A extends Comparable<? super A>> EBoolean notIn(Expr<A> left, A... rest) {
|
||||
public static <A> EBoolean notIn(Expr<A> left, A... rest) {
|
||||
return createBoolean(Ops.NOTIN, left, createConstant(rest));
|
||||
}
|
||||
|
||||
@ -797,7 +813,7 @@ public class Grammar extends Factory{
|
||||
* @param right
|
||||
* @return
|
||||
*/
|
||||
public static <A> EBoolean notIn(Expr<A> left, CollectionType<A> right){
|
||||
public static <A> EBoolean notIn(Expr<A> left, CollectionType<? extends A> right){
|
||||
return createBoolean(Ops.NOTIN, left, (Expr<?>)right);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package com.mysema.query.grammar.types;
|
||||
|
||||
import com.mysema.query.grammar.Grammar;
|
||||
import com.mysema.query.grammar.types.Expr.EEntity;
|
||||
import com.mysema.query.grammar.types.Expr.ESimple;
|
||||
import com.mysema.query.grammar.types.Path.PEntity;
|
||||
@ -62,9 +61,6 @@ public interface Alias {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
public Expr<D> as(String to) {
|
||||
return Grammar.as(this, to);
|
||||
}
|
||||
public Expr<?> getFrom() {return from;}
|
||||
public String getTo() {return to;}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import static com.mysema.query.grammar.types.Factory.createBoolean;
|
||||
import static com.mysema.query.grammar.types.Factory.createConstant;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang.ClassUtils;
|
||||
|
||||
@ -29,12 +30,25 @@ public abstract class Expr<D>{
|
||||
private final Class<? extends D> type;
|
||||
private String toString;
|
||||
|
||||
public Expr(Class<? extends D> type){this.type = type;}
|
||||
public EBoolean eq(D right){return Grammar.eq(this, right);}
|
||||
public EBoolean eq(Expr<? super D> right){return Grammar.eq(this, right);}
|
||||
public Expr(Class<? extends D> type){this.type = type;}
|
||||
public Class<? extends D> getType(){ return type;}
|
||||
public EBoolean ne(D right){return Grammar.ne(this, right);}
|
||||
public EBoolean ne(Expr<? super D> right){return Grammar.ne(this, right);}
|
||||
|
||||
// eq
|
||||
public final EBoolean eq(D right){return Grammar.eq(this, right);}
|
||||
public final EBoolean eq(Expr<? super D> right){return Grammar.eq(this, right);}
|
||||
|
||||
// ne
|
||||
public final EBoolean ne(D right){return Grammar.ne(this, right);}
|
||||
public final EBoolean ne(Expr<? super D> right){return Grammar.ne(this, right);}
|
||||
|
||||
// containment
|
||||
public final EBoolean in(CollectionType<? extends D> arg) {return Grammar.in(this, arg);}
|
||||
public final EBoolean in(Collection<? extends D> arg) {return Grammar.in(this, arg); }
|
||||
public final EBoolean in(D... args) {return Grammar.in(this,args);}
|
||||
|
||||
public final EBoolean notIn(CollectionType<? extends D> arg) {return Grammar.notIn(this, arg);}
|
||||
public final EBoolean notIn(Collection<? extends D> arg) {return Grammar.in(this, arg); }
|
||||
public final EBoolean notIn(D...args) {return Grammar.notIn(this, args);}
|
||||
|
||||
public String toString(){
|
||||
if (toString == null){
|
||||
@ -53,47 +67,42 @@ public abstract class Expr<D>{
|
||||
super(null, args);
|
||||
this.elementType = type;
|
||||
}
|
||||
public Class<D> getElementType(){
|
||||
public final Class<D> getElementType(){
|
||||
return elementType;
|
||||
}
|
||||
}
|
||||
public static abstract class EBoolean extends EComparable<Boolean>{
|
||||
private EBoolean not;
|
||||
public EBoolean() {super(Boolean.class);}
|
||||
public EBoolean and(EBoolean right) {return Grammar.and(this, right);}
|
||||
public EBoolean not(){
|
||||
public final EBoolean and(EBoolean right) {return Grammar.and(this, right);}
|
||||
public final EBoolean not(){
|
||||
return not == null ? not = Grammar.not(this) : not;
|
||||
}
|
||||
public EBoolean or(EBoolean right) {return Grammar.or(this, right);}
|
||||
public final EBoolean or(EBoolean right) {return Grammar.or(this, right);}
|
||||
}
|
||||
public static abstract class EComparable<D extends Comparable<? super D>> extends ESimple<D>{
|
||||
public EComparable(Class<? extends D> type) {super(type);}
|
||||
public EBoolean after(D right) {return Grammar.after(this,right);}
|
||||
public EBoolean after(Expr<D> right) {return Grammar.after(this,right);}
|
||||
public EBoolean aoe(D right) {return Grammar.aoe(this,right);}
|
||||
public EBoolean aoe(Expr<D> right) {return Grammar.aoe(this,right);}
|
||||
public final EBoolean after(D right) {return Grammar.after(this,right);}
|
||||
public final EBoolean after(Expr<D> right) {return Grammar.after(this,right);}
|
||||
public final EBoolean aoe(D right) {return Grammar.aoe(this,right);}
|
||||
public final EBoolean aoe(Expr<D> right) {return Grammar.aoe(this,right);}
|
||||
|
||||
public OrderSpecifier<D> asc() {return Grammar.asc(this);}
|
||||
public EBoolean before(D right) {return Grammar.before(this,right);}
|
||||
public EBoolean before(Expr<D> right) {return Grammar.before(this,right);}
|
||||
public EBoolean between(D first, D second) {return Grammar.between(this,first,second);}
|
||||
public final OrderSpecifier<D> asc() {return Grammar.asc(this);}
|
||||
public final EBoolean before(D right) {return Grammar.before(this,right);}
|
||||
public final EBoolean before(Expr<D> right) {return Grammar.before(this,right);}
|
||||
public final EBoolean between(D first, D second) {return Grammar.between(this,first,second);}
|
||||
|
||||
public EBoolean between(Expr<D> first, Expr<D> second) {return Grammar.between(this,first,second);}
|
||||
public EBoolean boe(D right) {return Grammar.boe(this,right);}
|
||||
public final EBoolean between(Expr<D> first, Expr<D> second) {return Grammar.between(this,first,second);}
|
||||
public final EBoolean boe(D right) {return Grammar.boe(this,right);}
|
||||
|
||||
public EBoolean boe(Expr<D> right) {return Grammar.boe(this,right);}
|
||||
public final EBoolean boe(Expr<D> right) {return Grammar.boe(this,right);}
|
||||
// cast methods
|
||||
public <A extends Number & Comparable<? super A>> ENumber<A> castToNum(Class<A> type){
|
||||
return Grammar.numericCast(this, type);
|
||||
}
|
||||
public OrderSpecifier<D> desc() {return Grammar.desc(this);}
|
||||
public EBoolean in(CollectionType<D> arg) {return Grammar.in(this, arg);}
|
||||
public EBoolean in(D... args) {return Grammar.in(this,args);}
|
||||
public EBoolean notBetween(D first, D second) {return Grammar.notBetween(this, first, second);}
|
||||
public EBoolean notBetween(Expr<D> first, Expr<D> second) {return Grammar.notBetween(this,first,second);}
|
||||
public EBoolean notIn(CollectionType<D> arg) {return Grammar.notIn(this, arg);}
|
||||
|
||||
public EBoolean notIn(D...args) {return Grammar.notIn(this, args);}
|
||||
public final OrderSpecifier<D> desc() {return Grammar.desc(this);}
|
||||
public final EBoolean notBetween(D first, D second) {return Grammar.notBetween(this, first, second);}
|
||||
public final EBoolean notBetween(Expr<D> first, Expr<D> second) {return Grammar.notBetween(this,first,second);}
|
||||
|
||||
public EString stringValue(){
|
||||
return Grammar.stringCast(this);
|
||||
@ -108,7 +117,7 @@ public abstract class Expr<D>{
|
||||
super(type);
|
||||
this.args = args;
|
||||
}
|
||||
public Expr<?>[] getArgs() {
|
||||
public final Expr<?>[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
@ -171,74 +180,72 @@ public abstract class Expr<D>{
|
||||
public static abstract class ENumber<D extends Number & Comparable<? super D>> extends EComparable<D>{
|
||||
public ENumber(Class<? extends D> type) {super(type);}
|
||||
|
||||
public ENumber<Byte> byteValue() { return castToNum(Byte.class); }
|
||||
public ENumber<Double> doubleValue() { return castToNum(Double.class); }
|
||||
public ENumber<Float> floatValue() { return castToNum(Float.class); }
|
||||
public final ENumber<Byte> byteValue() { return castToNum(Byte.class); }
|
||||
public final ENumber<Double> doubleValue() { return castToNum(Double.class); }
|
||||
public final ENumber<Float> floatValue() { return castToNum(Float.class); }
|
||||
// with Java level cast
|
||||
public <A extends Number & Comparable<? super A>> EBoolean goe(A right) { return createBoolean(Ops.GOE, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean goe(A right) { return createBoolean(Ops.GOE, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
|
||||
// without cast
|
||||
public <A extends Number & Comparable<? super A>> EBoolean goe(Expr<A> right) {return createBoolean(Ops.GOE, this, right);}
|
||||
public <A extends Number & Comparable<? super A>> EBoolean gt(A right) { return createBoolean(Ops.GT, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public <A extends Number & Comparable<? super A>> EBoolean gt(Expr<A> right) {return createBoolean(Ops.GT, this, right);}
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean goe(Expr<A> right) {return createBoolean(Ops.GOE, this, right);}
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean gt(A right) { return createBoolean(Ops.GT, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean gt(Expr<A> right) {return createBoolean(Ops.GT, this, right);}
|
||||
public ENumber<Integer> intValue() { return castToNum(Integer.class); }
|
||||
|
||||
public <A extends Number & Comparable<? super A>> EBoolean loe(A right) { return createBoolean(Ops.LOE, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public <A extends Number & Comparable<? super A>> EBoolean loe(Expr<A> right) {return createBoolean(Ops.LOE, this, right);}
|
||||
public ENumber<Long> longValue() { return castToNum(Long.class); }
|
||||
public <A extends Number & Comparable<? super A>> EBoolean lt(A right) { return createBoolean(Ops.LT, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public <A extends Number & Comparable<? super A>> EBoolean lt(Expr<A> right) {return createBoolean(Ops.LT, this, right);}
|
||||
public ENumber<Short> shortValue() { return castToNum(Short.class); }
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean loe(A right) { return createBoolean(Ops.LOE, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean loe(Expr<A> right) {return createBoolean(Ops.LOE, this, right);}
|
||||
public final ENumber<Long> longValue() { return castToNum(Long.class); }
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean lt(A right) { return createBoolean(Ops.LT, this, createConstant(NumberUtil.castTo(right,getType())));}
|
||||
public final <A extends Number & Comparable<? super A>> EBoolean lt(Expr<A> right) {return createBoolean(Ops.LT, this, right);}
|
||||
public final ENumber<Short> shortValue() { return castToNum(Short.class); }
|
||||
}
|
||||
|
||||
public static abstract class ESimple<D> extends Expr<D>{
|
||||
public ESimple(Class<? extends D> type) {super(type);}
|
||||
public Expr<D> as(String to){return Grammar.as(this, to);}
|
||||
public EBoolean in(CollectionType<D> arg) {return Grammar.in(this, arg);}
|
||||
public EBoolean in(D... args) {return Grammar.in(this,args);}
|
||||
public final Expr<D> as(String to){return Grammar.as(this, to);}
|
||||
}
|
||||
|
||||
public static abstract class EString extends EComparable<String>{
|
||||
private EString lower, trim, upper;
|
||||
public EString() {super(String.class);}
|
||||
|
||||
public EString add(Expr<String> str) {return Grammar.concat(this, str);}
|
||||
public EString add(String str) {return Grammar.concat(this, str);}
|
||||
public final EString add(Expr<String> str) {return Grammar.concat(this, str);}
|
||||
public final EString add(String str) {return Grammar.concat(this, str);}
|
||||
|
||||
public Expr<Character> charAt(Expr<Integer> i) {return Grammar.charAt(this, i);}
|
||||
public Expr<Character> charAt(int i) {return Grammar.charAt(this, i);}
|
||||
public final Expr<Character> charAt(Expr<Integer> i) {return Grammar.charAt(this, i);}
|
||||
public final Expr<Character> charAt(int i) {return Grammar.charAt(this, i);}
|
||||
|
||||
public EString concat(Expr<String> str) {return Grammar.concat(this, str);}
|
||||
public EString concat(String str) {return Grammar.concat(this, str);}
|
||||
public final EString concat(Expr<String> str) {return Grammar.concat(this, str);}
|
||||
public final EString concat(String str) {return Grammar.concat(this, str);}
|
||||
|
||||
public EBoolean contains(Expr<String> str) {return Grammar.contains(this, str);}
|
||||
public EBoolean contains(String str) {return Grammar.contains(this, str);}
|
||||
public final EBoolean contains(Expr<String> str) {return Grammar.contains(this, str);}
|
||||
public final EBoolean contains(String str) {return Grammar.contains(this, str);}
|
||||
|
||||
public EBoolean endsWith(Expr<String> str) {return Grammar.endsWith(this, str);}
|
||||
public EBoolean endsWith(String str) {return Grammar.endsWith(this, str);}
|
||||
public final EBoolean endsWith(Expr<String> str) {return Grammar.endsWith(this, str);}
|
||||
public final EBoolean endsWith(String str) {return Grammar.endsWith(this, str);}
|
||||
|
||||
public EBoolean equalsIgnoreCase(Expr<String> str) {return Grammar.equalsIgnoreCase(this, str);}
|
||||
public EBoolean equalsIgnoreCase(String str) {return Grammar.equalsIgnoreCase(this, str);}
|
||||
public final EBoolean equalsIgnoreCase(Expr<String> str) {return Grammar.equalsIgnoreCase(this, str);}
|
||||
public final EBoolean equalsIgnoreCase(String str) {return Grammar.equalsIgnoreCase(this, str);}
|
||||
|
||||
public EComparable<Integer> indexOf(Expr<String> str) {return Grammar.indexOf(this, str);}
|
||||
public EComparable<Integer> indexOf(String str) {return Grammar.indexOf(this, str);}
|
||||
public EComparable<Integer> indexOf(String str, int i) {return Grammar.indexOf(this, str, i);}
|
||||
public EComparable<Integer> lastIndex(String str, int i) {return Grammar.lastIndex(this, str, i);}
|
||||
public EComparable<Integer> lastIndexOf(String str) {return Grammar.lastIndexOf(this, str);}
|
||||
public final EComparable<Integer> indexOf(Expr<String> str) {return Grammar.indexOf(this, str);}
|
||||
public final EComparable<Integer> indexOf(String str) {return Grammar.indexOf(this, str);}
|
||||
public final EComparable<Integer> indexOf(String str, int i) {return Grammar.indexOf(this, str, i);}
|
||||
public final EComparable<Integer> lastIndex(String str, int i) {return Grammar.lastIndex(this, str, i);}
|
||||
public final EComparable<Integer> lastIndexOf(String str) {return Grammar.lastIndexOf(this, str);}
|
||||
|
||||
public EComparable<Integer> length() {return Grammar.length(this);}
|
||||
public final EComparable<Integer> length() {return Grammar.length(this);}
|
||||
|
||||
public EBoolean like(String str) { return Grammar.like(this, str); }
|
||||
public final EBoolean like(String str) { return Grammar.like(this, str); }
|
||||
|
||||
public EString lower() { return lower == null ? lower = Grammar.lower(this) : lower; }
|
||||
public final EString lower() { return lower == null ? lower = Grammar.lower(this) : lower; }
|
||||
|
||||
public EBoolean startsWith(Expr<String> str) {return Grammar.startsWith(this, str);}
|
||||
public EBoolean startsWith(String str) {return Grammar.startsWith(this, str);}
|
||||
public final EBoolean startsWith(Expr<String> str) {return Grammar.startsWith(this, str);}
|
||||
public final EBoolean startsWith(String str) {return Grammar.startsWith(this, str);}
|
||||
|
||||
public EString substring(int beginIndex) { return Grammar.substring(this, beginIndex);}
|
||||
public EString substring(int beginIndex, int endIndex) { return Grammar.substring(this, beginIndex, endIndex);}
|
||||
public final EString substring(int beginIndex) { return Grammar.substring(this, beginIndex);}
|
||||
public final EString substring(int beginIndex, int endIndex) { return Grammar.substring(this, beginIndex, endIndex);}
|
||||
|
||||
public EString trim() { return trim == null ? trim = Grammar.trim(this) : trim; }
|
||||
public EString upper() { return upper == null ? upper = Grammar.upper(this) : upper; }
|
||||
public final EString trim() { return trim == null ? trim = Grammar.trim(this) : trim; }
|
||||
public final EString upper() { return upper == null ? upper = Grammar.upper(this) : upper; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import static com.mysema.query.grammar.types.PathMetadata.forProperty;
|
||||
import static com.mysema.query.grammar.types.PathMetadata.forSize;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mysema.query.grammar.Grammar;
|
||||
import com.mysema.query.grammar.types.Expr.*;
|
||||
@ -29,6 +30,7 @@ public interface Path<C> {
|
||||
Path<?> getRoot();
|
||||
EBoolean isnotnull();
|
||||
EBoolean isnull();
|
||||
Class<? extends C> getType();
|
||||
|
||||
public static abstract class PArray<D> extends Expr<D[]> implements Path<D[]>, CollectionType<D>{
|
||||
protected final Class<D[]> arrayType;
|
||||
@ -353,7 +355,6 @@ public interface Path<C> {
|
||||
public Alias.AEntity<D> as(PEntity<D> to) {return Grammar.as(this, to);}
|
||||
public String getEntityName(){ return entityName; }
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean in(CollectionType<D> right){return Grammar.in(this, right);}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
}
|
||||
@ -435,7 +436,7 @@ public interface Path<C> {
|
||||
|
||||
}
|
||||
|
||||
public static class PEntityMap<K,V> extends EEntity<PMap<K,V>> implements PMap<K,V>{
|
||||
public static class PEntityMap<K,V> extends EEntity<Map<K,V>> implements PMap<K,V>{
|
||||
private EBoolean isnull, isnotnull;
|
||||
private final Class<K> keyType;
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user