mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
added annotations and sql modules
renamed Simple to Literal in Expr and Path
This commit is contained in:
parent
5dc04f36bc
commit
0dc86ac82c
@ -23,9 +23,9 @@ public interface Query<A extends Query<A>>{
|
||||
@Deprecated A join(Entity<?> o);
|
||||
@Deprecated A fullJoin(Entity<?> o);
|
||||
@Deprecated A leftJoin(Entity<?> o);
|
||||
@Deprecated A with(Expr.Boolean... o);
|
||||
A where(Expr.Boolean... o);
|
||||
@Deprecated A with(Expr.Boolean o);
|
||||
A where(Expr.Boolean o);
|
||||
A groupBy(Expr<?>... o);
|
||||
A having(Expr.Boolean... o);
|
||||
A having(Expr.Boolean o);
|
||||
A orderBy(OrderSpecifier<?>... o);
|
||||
}
|
||||
@ -23,7 +23,7 @@ import static com.mysema.query.grammar.types.Expr.*;
|
||||
public class QueryBase<A extends QueryBase<A>> implements Query<A> {
|
||||
protected final List<Expr<?>> groupBy = new ArrayList<Expr<?>>();
|
||||
|
||||
protected final List<Expr.Boolean> having = new ArrayList<Expr.Boolean>();
|
||||
protected final CascadingBoolean having = new CascadingBoolean();
|
||||
|
||||
protected final List<JoinExpression> joins = new ArrayList<JoinExpression>();
|
||||
protected final List<OrderSpecifier<?>> orderBy = new ArrayList<OrderSpecifier<?>>();
|
||||
@ -52,8 +52,8 @@ public class QueryBase<A extends QueryBase<A>> implements Query<A> {
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A having(Expr.Boolean... o) {
|
||||
having.addAll(Arrays.asList(o));
|
||||
public A having(Expr.Boolean o) {
|
||||
having.and(o);
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
@ -87,18 +87,14 @@ public class QueryBase<A extends QueryBase<A>> implements Query<A> {
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A where(Expr.Boolean... o) {
|
||||
for (Expr.Boolean expr : o){
|
||||
where.and(expr);
|
||||
}
|
||||
public A where(Expr.Boolean o) {
|
||||
where.and(o);
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
public A with(Expr.Boolean... o) {
|
||||
public A with(Expr.Boolean o) {
|
||||
if (!joins.isEmpty()){
|
||||
CascadingBoolean cb = new CascadingBoolean();
|
||||
for (Expr.Boolean expr : o) cb.and(expr);
|
||||
joins.get(joins.size()-1).setCondition(cb.self());
|
||||
joins.get(joins.size()-1).setCondition(o);
|
||||
}
|
||||
return (A) this;
|
||||
}
|
||||
@ -111,8 +107,8 @@ public class QueryBase<A extends QueryBase<A>> implements Query<A> {
|
||||
public List<Expr<?>> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
public List<Expr.Boolean> getHaving() {
|
||||
return having;
|
||||
public Expr.Boolean getHaving() {
|
||||
return having.self();
|
||||
}
|
||||
public List<JoinExpression> getJoins() {
|
||||
return joins;
|
||||
|
||||
@ -10,7 +10,6 @@ import static com.mysema.query.grammar.types.Factory.createBoolean;
|
||||
import static com.mysema.query.grammar.types.Factory.createConstant;
|
||||
import static com.mysema.query.grammar.types.Factory.createNumber;
|
||||
|
||||
import com.mysema.query.grammar.Ops.Op;
|
||||
import com.mysema.query.grammar.types.Expr;
|
||||
import com.mysema.query.grammar.types.Expr.CollectionType;
|
||||
|
||||
|
||||
@ -37,10 +37,10 @@ public class Alias {
|
||||
public Path<?> getTo() {return to;}
|
||||
}
|
||||
|
||||
public static class NoEntity<D> extends Expr.NoEntity<D> implements Simple{
|
||||
public static class Literal<D> extends Expr.Literal<D>{
|
||||
private final Expr<?> from;
|
||||
private final java.lang.String to;
|
||||
public NoEntity(Expr<D> from, java.lang.String to) {
|
||||
public Literal(Expr<D> from, java.lang.String to) {
|
||||
super(from.getType());
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
@ -52,10 +52,10 @@ public class Alias {
|
||||
public java.lang.String getTo() {return to;}
|
||||
}
|
||||
|
||||
public interface Simple{
|
||||
Expr<?> getFrom();
|
||||
String getTo();
|
||||
}
|
||||
// public interface Simple{
|
||||
// Expr<?> getFrom();
|
||||
// String getTo();
|
||||
// }
|
||||
|
||||
public interface ToPath{
|
||||
Expr<?> getFrom();
|
||||
|
||||
@ -7,8 +7,6 @@ package com.mysema.query.grammar.types;
|
||||
|
||||
import com.mysema.query.grammar.OrderSpecifier;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Expr provides
|
||||
*
|
||||
@ -35,7 +33,7 @@ public abstract class Expr<D> {
|
||||
// public Boolean ne(Expr<? super D> right){return IntGrammar.ne(this, right);}
|
||||
// }
|
||||
|
||||
public static abstract class Boolean extends NoEntity<java.lang.Boolean>{
|
||||
public static abstract class Boolean extends Literal<java.lang.Boolean>{
|
||||
public Boolean() {super(java.lang.Boolean.class);}
|
||||
public Boolean and(Boolean right) {return IntGrammar.and(this, right);}
|
||||
public Boolean or(Boolean right) {return IntGrammar.or(this, right);}
|
||||
@ -45,7 +43,7 @@ public abstract class Expr<D> {
|
||||
|
||||
}
|
||||
|
||||
public static abstract class Comparable<D extends java.lang.Comparable<D>> extends NoEntity<D>{
|
||||
public static abstract class Comparable<D extends java.lang.Comparable<D>> extends Literal<D>{
|
||||
public Comparable(Class<D> type) {super(type);}
|
||||
public Boolean after(D right) {return IntGrammar.after(this,right);}
|
||||
public Boolean after(Expr<D> right) {return IntGrammar.after(this,right);}
|
||||
@ -94,8 +92,8 @@ public abstract class Expr<D> {
|
||||
public Entity(Class<D> type) {super(type);}
|
||||
}
|
||||
|
||||
public static abstract class NoEntity<D> extends Expr<D>{
|
||||
public NoEntity(Class<D> type) {super(type);}
|
||||
public static abstract class Literal<D> extends Expr<D>{
|
||||
public Literal(Class<D> type) {super(type);}
|
||||
public Expr<D> as(java.lang.String to){return IntGrammar.as(this, to);}
|
||||
}
|
||||
|
||||
|
||||
@ -55,10 +55,10 @@ class IntGrammar{
|
||||
return createBoolean(Ops.AND, left, right);
|
||||
}
|
||||
|
||||
static <D> Alias.NoEntity<D> as(Expr.NoEntity<D> from, String to) {
|
||||
static <D> Alias.Literal<D> as(Expr.Literal<D> from, String to) {
|
||||
checkArg("from",from);
|
||||
checkArg("to",to);
|
||||
return new Alias.NoEntity<D>(from, to);
|
||||
return new Alias.Literal<D>(from, to);
|
||||
}
|
||||
|
||||
static <D> Alias.Entity<D> as(Path.Entity<D> from, Path.Entity<D> to) {
|
||||
|
||||
@ -30,7 +30,7 @@ public interface Path<C> {
|
||||
// ExprBoolean isnull();
|
||||
// }
|
||||
|
||||
public static class Boolean extends Expr.Boolean implements NoEntity<java.lang.Boolean>{
|
||||
public static class Boolean extends Expr.Boolean implements Literal<java.lang.Boolean>{
|
||||
private final PathMetadata<java.lang.String> metadata;
|
||||
public Boolean(PathMetadata<java.lang.String> metadata) {
|
||||
this.metadata = metadata;
|
||||
@ -47,7 +47,7 @@ public interface Path<C> {
|
||||
Expr.Comparable<Integer> size();
|
||||
}
|
||||
|
||||
public static class Comparable<D extends java.lang.Comparable<D>> extends Expr.Comparable<D> implements NoEntity<D>{
|
||||
public static class Comparable<D extends java.lang.Comparable<D>> extends Expr.Comparable<D> implements Literal<D>{
|
||||
private final PathMetadata<?> metadata;
|
||||
public Comparable(Class<D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
@ -58,7 +58,7 @@ public interface Path<C> {
|
||||
public Expr.Boolean isnull() {return IntGrammar.isnull(this);}
|
||||
}
|
||||
|
||||
public static class ComponentCollection<D> extends Expr.NoEntity<java.util.Collection<D>> implements Collection<D>{
|
||||
public static class ComponentCollection<D> extends Expr.Literal<java.util.Collection<D>> implements Collection<D>{
|
||||
private final PathMetadata<?> metadata;
|
||||
private final Class<D> type;
|
||||
public ComponentCollection(Class<D> type, PathMetadata<?> metadata) {
|
||||
@ -66,11 +66,11 @@ public interface Path<C> {
|
||||
this.type = type;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
public Expr.NoEntity<D> get(Expr<Integer> index) {
|
||||
return new NoEntitySimple<D>(type, forListAccess(this, index));
|
||||
public Expr.Literal<D> get(Expr<Integer> index) {
|
||||
return new SimpleLiteral<D>(type, forListAccess(this, index));
|
||||
}
|
||||
public Expr.NoEntity<D> get(int index) {
|
||||
return new NoEntitySimple<D>(type, forListAccess(this, index));
|
||||
public Expr.Literal<D> get(int index) {
|
||||
return new SimpleLiteral<D>(type, forListAccess(this, index));
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public Expr.Boolean isnotnull() {return IntGrammar.isnotnull(this);}
|
||||
@ -82,7 +82,7 @@ public interface Path<C> {
|
||||
public Class<D> getElementType() {return type;}
|
||||
}
|
||||
|
||||
public static class ComponentMap<K,V> extends Expr.NoEntity<java.util.Map<K,V>> implements Map<K,V>{
|
||||
public static class ComponentMap<K,V> extends Expr.Literal<java.util.Map<K,V>> implements Map<K,V>{
|
||||
private final PathMetadata<?> metadata;
|
||||
private final Class<K> keyType;
|
||||
private final Class<V> valueType;
|
||||
@ -92,11 +92,11 @@ public interface Path<C> {
|
||||
this.valueType = valueType;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
public Expr.NoEntity<V> get(Expr<K> key) {
|
||||
return new NoEntitySimple<V>(valueType, forMapAccess(this, key));
|
||||
public Expr.Literal<V> get(Expr<K> key) {
|
||||
return new SimpleLiteral<V>(valueType, forMapAccess(this, key));
|
||||
}
|
||||
public Expr.NoEntity<V> get(K key) {
|
||||
return new NoEntitySimple<V>(valueType, forMapAccess(this, key));
|
||||
public Expr.Literal<V> get(K key) {
|
||||
return new SimpleLiteral<V>(valueType, forMapAccess(this, key));
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public Expr.Boolean isnotnull() {return IntGrammar.isnotnull(this);}
|
||||
@ -121,14 +121,14 @@ public interface Path<C> {
|
||||
protected <A extends java.lang.Comparable<A>> Path.Comparable<A> _comparable(java.lang.String path,Class<A> type) {
|
||||
return new Path.Comparable<A>(type, forProperty(this, path));
|
||||
}
|
||||
protected <A> EntityRenamable<A> _entity(java.lang.String path, Class<A> type){
|
||||
return new EntityRenamable<A>(type, forProperty(this, path));
|
||||
protected <A> RenamableEntity<A> _entity(java.lang.String path, Class<A> type){
|
||||
return new RenamableEntity<A>(type, forProperty(this, path));
|
||||
}
|
||||
protected <A> EntityCollection<A> _entitycol(java.lang.String path,Class<A> type) {
|
||||
return new EntityCollection<A>(type, forProperty(this, path));
|
||||
}
|
||||
protected <A> NoEntitySimple<A> _simple(java.lang.String path, Class<A> type){
|
||||
return new NoEntitySimple<A>(type, forProperty(this, path));
|
||||
protected <A> SimpleLiteral<A> _simple(java.lang.String path, Class<A> type){
|
||||
return new SimpleLiteral<A>(type, forProperty(this, path));
|
||||
}
|
||||
protected <A> ComponentCollection<A> _simplecol(java.lang.String path,Class<A> type) {
|
||||
return new ComponentCollection<A>(type, forProperty(this, path));
|
||||
@ -193,8 +193,8 @@ public interface Path<C> {
|
||||
public Class<V> getValueType() {return valueType; }
|
||||
}
|
||||
|
||||
public static class EntityRenamable<D> extends Entity<D>{
|
||||
protected EntityRenamable(Class<D> type, PathMetadata<?> metadata) {super(type, metadata);}
|
||||
public static class RenamableEntity<D> extends Entity<D>{
|
||||
protected RenamableEntity(Class<D> type, PathMetadata<?> metadata) {super(type, metadata);}
|
||||
public Alias.Entity<D> as(Path.Entity<D> to) {return IntGrammar.as(this, to);}
|
||||
}
|
||||
|
||||
@ -205,13 +205,13 @@ public interface Path<C> {
|
||||
Class<V> getValueType();
|
||||
}
|
||||
|
||||
public interface NoEntity<D> extends Path<D>{
|
||||
public interface Literal<D> extends Path<D>{
|
||||
Expr<D> as(java.lang.String to);
|
||||
}
|
||||
|
||||
public static class NoEntitySimple<D> extends Expr.NoEntity<D> implements NoEntity<D>{
|
||||
public static class SimpleLiteral<D> extends Expr.Literal<D> implements Literal<D>{
|
||||
private final PathMetadata<?> metadata;
|
||||
public <T> NoEntitySimple(Class<D> type, PathMetadata<?> metadata) {
|
||||
public <T> SimpleLiteral(Class<D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
@ -220,7 +220,7 @@ public interface Path<C> {
|
||||
public Expr.Boolean isnull() {return IntGrammar.isnull(this);}
|
||||
}
|
||||
|
||||
public static class String extends Expr.String implements NoEntity<java.lang.String>{
|
||||
public static class String extends Expr.String implements Literal<java.lang.String>{
|
||||
private final PathMetadata<java.lang.String> metadata;
|
||||
public String(PathMetadata<java.lang.String> metadata) {
|
||||
this.metadata = metadata;
|
||||
|
||||
@ -72,20 +72,18 @@ public final class PathMetadata<T> {
|
||||
|
||||
public PathType getPathType() {
|
||||
return pathType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type provides
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
public static class PathType extends Ops.Op<Path<?>> {}
|
||||
|
||||
public static PathType LISTVALUE = new PathType();
|
||||
public static PathType LISTVALUE_CONSTANT = new PathType();
|
||||
public static PathType MAPVALUE = new PathType();
|
||||
public static PathType MAPVALUE_CONSTANT = new PathType();
|
||||
public static PathType PROPERTY = new PathType();
|
||||
public static PathType VARIABLE = new PathType();
|
||||
public static PathType SIZE = new PathType();
|
||||
// bookmark.tags.size
|
||||
|
||||
public static final PathType LISTVALUE = new PathType();
|
||||
public static final PathType LISTVALUE_CONSTANT = new PathType();
|
||||
public static final PathType MAPVALUE = new PathType();
|
||||
public static final PathType MAPVALUE_CONSTANT = new PathType();
|
||||
public static final PathType PROPERTY = new PathType();
|
||||
public static final PathType VARIABLE = new PathType();
|
||||
public static final PathType SIZE = new PathType();
|
||||
|
||||
}
|
||||
|
||||
@ -67,9 +67,9 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
protected abstract void visit(Alias.EntityCollection<?> expr);
|
||||
|
||||
protected abstract void visit(Alias.NoEntity<?> expr);
|
||||
protected abstract void visit(Alias.Literal<?> expr);
|
||||
|
||||
protected abstract void visit(Alias.Simple expr);
|
||||
// protected abstract void visit(Alias.Simple expr);
|
||||
|
||||
protected abstract void visit(Alias.ToPath expr);
|
||||
|
||||
@ -101,11 +101,11 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
protected abstract void visit(Path.EntityMap<?,?> expr);
|
||||
|
||||
protected abstract void visit(Path.EntityRenamable<?> expr);
|
||||
protected abstract void visit(Path.RenamableEntity<?> expr);
|
||||
|
||||
protected abstract void visit(Path.NoEntity<?> expr);
|
||||
protected abstract void visit(Path.Literal<?> expr);
|
||||
|
||||
protected abstract void visit(Path.NoEntitySimple<?> expr);
|
||||
protected abstract void visit(Path.SimpleLiteral<?> expr);
|
||||
|
||||
protected abstract void visit(Path.String expr);
|
||||
|
||||
|
||||
@ -24,10 +24,10 @@ public abstract class VisitorAdapter<V extends VisitorAdapter<V>> extends Visito
|
||||
protected void visit(Alias.EntityCollection<?> expr) {
|
||||
visit((Alias.ToPath) expr);
|
||||
}
|
||||
@Override
|
||||
protected void visit(Alias.NoEntity<?> expr) {
|
||||
visit((Alias.Simple) expr);
|
||||
}
|
||||
// @Override
|
||||
// protected void visit(Alias.Literal<?> expr) {
|
||||
// visit((Alias.Simple) expr);
|
||||
// }
|
||||
@Override
|
||||
protected void visit(Operation.Boolean expr) {
|
||||
visit((Operation<?, ?>) expr);
|
||||
@ -76,18 +76,18 @@ public abstract class VisitorAdapter<V extends VisitorAdapter<V>> extends Visito
|
||||
visit((Path.Map<?,?>) expr);
|
||||
}
|
||||
@Override
|
||||
protected void visit(Path.EntityRenamable<?> expr) {
|
||||
protected void visit(Path.RenamableEntity<?> expr) {
|
||||
visit((Path.Entity<?>) expr);
|
||||
}
|
||||
protected void visit(Path.Map<?,?> expr){
|
||||
visit((Path<?>) expr);
|
||||
}
|
||||
@Override
|
||||
protected void visit(Path.NoEntity<?> expr) {
|
||||
protected void visit(Path.Literal<?> expr) {
|
||||
visit((Path<?>) expr);
|
||||
}
|
||||
@Override
|
||||
protected void visit(Path.NoEntitySimple<?> expr) {
|
||||
protected void visit(Path.SimpleLiteral<?> expr) {
|
||||
visit((Path<?>) expr);
|
||||
}
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user