mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
added DefaultMetadata and QueryMetadata
updated Serializers and Query implementations to use them
This commit is contained in:
parent
1387bdfbf2
commit
7dc23aa893
@ -36,5 +36,9 @@ public class CascadingBoolean {
|
||||
public Expr.EBoolean create(){
|
||||
return expr;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return expr != null ? expr.toString() : super.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
package com.mysema.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.query.grammar.OrderSpecifier;
|
||||
import com.mysema.query.grammar.types.Expr;
|
||||
import com.mysema.query.grammar.types.Expr.EBoolean;
|
||||
|
||||
/**
|
||||
* DefaultMetadata provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultMetadata<JoinMeta> implements QueryMetadata<JoinMeta>{
|
||||
|
||||
private List<? extends Expr<?>> groupBy;
|
||||
|
||||
private EBoolean having;
|
||||
|
||||
private List<JoinExpression<JoinMeta>> joins;
|
||||
|
||||
private List<OrderSpecifier<?>> orderBy;
|
||||
|
||||
private List<? extends Expr<?>> select;
|
||||
|
||||
private EBoolean where;
|
||||
|
||||
public List<? extends Expr<?>> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
|
||||
public void setGroupBy(List<? extends Expr<?>> groupBy) {
|
||||
this.groupBy = groupBy;
|
||||
}
|
||||
|
||||
public EBoolean getHaving() {
|
||||
return having;
|
||||
}
|
||||
|
||||
public void setHaving(EBoolean having) {
|
||||
this.having = having;
|
||||
}
|
||||
|
||||
public List<JoinExpression<JoinMeta>> getJoins() {
|
||||
return joins;
|
||||
}
|
||||
|
||||
public void setJoins(List<JoinExpression<JoinMeta>> joins) {
|
||||
this.joins = joins;
|
||||
}
|
||||
|
||||
public List<OrderSpecifier<?>> getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
public void setOrderBy(List<OrderSpecifier<?>> orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public List<? extends Expr<?>> getSelect() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public void setSelect(List<? extends Expr<?>> select) {
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
public EBoolean getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
public void setWhere(EBoolean where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -46,7 +46,26 @@ public class QueryBase<JoinMeta,SubType extends QueryBase<JoinMeta,SubType>> imp
|
||||
|
||||
protected String toString;
|
||||
|
||||
private final Metadata metadata = new Metadata();
|
||||
private final QueryMetadata<JoinMeta> metadata = new QueryMetadata<JoinMeta>(){
|
||||
public List<Expr<?>> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
public EBoolean getHaving() {
|
||||
return having.create();
|
||||
}
|
||||
public List<JoinExpression<JoinMeta>> getJoins() {
|
||||
return joins;
|
||||
}
|
||||
public List<OrderSpecifier<?>> getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
public List<Expr<?>> getSelect() {
|
||||
return select;
|
||||
}
|
||||
public EBoolean getWhere() {
|
||||
return where.create();
|
||||
}
|
||||
};
|
||||
|
||||
public SubType from(Expr<?>... o) {
|
||||
for (Expr<?> expr : o){
|
||||
@ -110,7 +129,7 @@ public class QueryBase<JoinMeta,SubType extends QueryBase<JoinMeta,SubType>> imp
|
||||
return _this;
|
||||
}
|
||||
|
||||
public Metadata getMetadata(){
|
||||
public QueryMetadata<JoinMeta> getMetadata(){
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@ -118,28 +137,5 @@ public class QueryBase<JoinMeta,SubType extends QueryBase<JoinMeta,SubType>> imp
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class Metadata.
|
||||
*/
|
||||
public class Metadata{
|
||||
public List<Expr<?>> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
public EBoolean getHaving() {
|
||||
return having.create();
|
||||
}
|
||||
public List<JoinExpression<JoinMeta>> getJoins() {
|
||||
return joins;
|
||||
}
|
||||
public List<OrderSpecifier<?>> getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
public List<Expr<?>> getSelect() {
|
||||
return select;
|
||||
}
|
||||
public EBoolean getWhere() {
|
||||
return where.create();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package com.mysema.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.query.grammar.OrderSpecifier;
|
||||
import com.mysema.query.grammar.types.Expr;
|
||||
import com.mysema.query.grammar.types.Expr.EBoolean;
|
||||
|
||||
/**
|
||||
* QueryMetadata provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface QueryMetadata<JoinMeta> {
|
||||
|
||||
List<? extends Expr<?>> getGroupBy();
|
||||
|
||||
EBoolean getHaving();
|
||||
|
||||
List<JoinExpression<JoinMeta>> getJoins();
|
||||
|
||||
List<OrderSpecifier<?>> getOrderBy();
|
||||
|
||||
List<? extends Expr<?>> getSelect();
|
||||
|
||||
EBoolean getWhere();
|
||||
|
||||
}
|
||||
@ -12,5 +12,14 @@ package com.mysema.query.grammar;
|
||||
* @version $Id$
|
||||
*/
|
||||
public enum Order {
|
||||
ASC, DESC
|
||||
ASC{
|
||||
public String toString(){
|
||||
return "asc";
|
||||
}
|
||||
},
|
||||
DESC{
|
||||
public String toString(){
|
||||
return "desc";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,4 +18,8 @@ import com.mysema.query.grammar.types.Expr;
|
||||
public class OrderSpecifier<A extends Comparable<? super A>> {
|
||||
public Order order;
|
||||
public Expr<A> target;
|
||||
|
||||
public String toString(){
|
||||
return target + " " + order;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user