mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
added stub for improved supertype handling in APT class generation
This commit is contained in:
parent
a0a5c28e54
commit
5ba230f56c
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.types;
|
||||
|
||||
import com.mysema.query.grammar.Ops.Op;
|
||||
import com.mysema.query.grammar.types.Expr.EBoolean;
|
||||
import com.mysema.query.grammar.types.Expr.EComparable;
|
||||
import com.mysema.query.grammar.types.Expr.ENumber;
|
||||
import com.mysema.query.grammar.types.Expr.EString;
|
||||
|
||||
/**
|
||||
* ExprFactory provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ExprFactory {
|
||||
|
||||
EBoolean createBoolean(Op<Boolean> operator, Expr<?>... args);
|
||||
|
||||
<OpType, RT extends Comparable<? super RT>> EComparable<RT> createComparable(Class<RT> type, Op<OpType> operator, Expr<?>... args);
|
||||
|
||||
<A> Expr<A> createConstant(A obj);
|
||||
|
||||
<OpType extends Number,D extends Number & Comparable<? super D>> ENumber<D> createNumber(Class<? extends D> type, Op<OpType> operator, Expr<?>... args);
|
||||
|
||||
EString createString(Op<String> operator, Expr<?>... args);
|
||||
|
||||
Expr<String[]> createStringArray(Op<String> operator, Expr<?>... args);
|
||||
|
||||
}
|
||||
@ -50,19 +50,23 @@ public interface Path<C> {
|
||||
public PArray(Class<D> type, String var){
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
public abstract Expr<D> get(Expr<Integer> index);
|
||||
public abstract Expr<D> get(int index);
|
||||
public Class<D> getElementType() {return componentType;}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public Class<D[]> getType(){ return arrayType;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public EComparable<Integer> size() {
|
||||
return size == null ? size = new PComparable<Integer>(Integer.class, forSize(this)) : size;
|
||||
public EComparable<Integer> size() {
|
||||
if (size == null) size = new PComparable<Integer>(Integer.class, forSize(this));
|
||||
return size;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
@ -88,11 +92,13 @@ public interface Path<C> {
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
}
|
||||
@ -141,11 +147,13 @@ public interface Path<C> {
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
}
|
||||
@ -171,11 +179,13 @@ public interface Path<C> {
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
}
|
||||
@ -220,13 +230,16 @@ public interface Path<C> {
|
||||
public Class<D> getElementType() {return type;}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
public EComparable<Integer> size() {
|
||||
return size == null ? size = new PComparable<Integer>(Integer.class, forSize(this)) : size;
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public EComparable<Integer> size() {
|
||||
if (size == null) size = new PComparable<Integer>(Integer.class, forSize(this));
|
||||
return size;
|
||||
}
|
||||
public EBoolean contains(D child) {
|
||||
return Grammar.in(child, this);
|
||||
@ -286,11 +299,13 @@ public interface Path<C> {
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public Class<V> getValueType() {return valueType; }
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
}
|
||||
@ -356,11 +371,13 @@ public interface Path<C> {
|
||||
public String getEntityName(){ return entityName; }
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public <B extends D> EBoolean typeOf(Class<B> type) {return Grammar.typeOf(this, type);}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
@ -395,13 +412,16 @@ public interface Path<C> {
|
||||
public String getEntityName() { return entityName; }
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public ENumber<Integer> size() {
|
||||
return size == null ? size = new PNumber<Integer>(Integer.class, forSize(this)) : size;
|
||||
if (size == null) size = new PNumber<Integer>(Integer.class, forSize(this));
|
||||
return size;
|
||||
}
|
||||
public EBoolean contains(D child) {
|
||||
return Grammar.in(child, this);
|
||||
@ -431,6 +451,7 @@ public interface Path<C> {
|
||||
return new PEntity<D>(type, entityName, forListAccess(this,index));
|
||||
}
|
||||
public PEntity<D> get(int index) {
|
||||
// cache
|
||||
return new PEntity<D>(type, entityName, forListAccess(this,index));
|
||||
}
|
||||
|
||||
@ -465,11 +486,13 @@ public interface Path<C> {
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public Class<V> getValueType() {return valueType; }
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
}
|
||||
@ -507,11 +530,13 @@ public interface Path<C> {
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return root;
|
||||
}
|
||||
@ -534,11 +559,13 @@ public interface Path<C> {
|
||||
}
|
||||
public PathMetadata<?> getMetadata() {return metadata;}
|
||||
public EBoolean isnotnull() {
|
||||
return isnotnull == null ? isnotnull = Grammar.isnotnull(this) : isnotnull;
|
||||
if (isnotnull == null) isnotnull = Grammar.isnotnull(this);
|
||||
return isnotnull;
|
||||
}
|
||||
public EBoolean isnull() {
|
||||
return isnull == null ? isnull = Grammar.isnull(this) : isnull;
|
||||
}
|
||||
if (isnull == null) isnull = Grammar.isnull(this);
|
||||
return isnull;
|
||||
}
|
||||
public Path<?> getRoot(){
|
||||
return metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
@ -561,6 +588,7 @@ public interface Path<C> {
|
||||
return new PString(forArrayAccess(this, index));
|
||||
}
|
||||
public EString get(int index) {
|
||||
// TODO : cache
|
||||
return new PString(forArrayAccess(this, index));
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,40 +56,31 @@ public final class PathMetadata<T> {
|
||||
this.hashCode = new HashCodeBuilder().append(expression).append(parent).append(pathType).hashCode();
|
||||
}
|
||||
|
||||
public static PathMetadata<Integer> forArrayAccess(Path.PArray<?> parent,
|
||||
Expr<Integer> index) {
|
||||
public static PathMetadata<Integer> forArrayAccess(Path.PArray<?> parent, Expr<Integer> index) {
|
||||
return new PathMetadata<Integer>(parent, index, ARRAYVALUE);
|
||||
}
|
||||
|
||||
public static PathMetadata<Integer> forArrayAccess(Path.PArray<?> parent,
|
||||
int index) {
|
||||
return new PathMetadata<Integer>(parent, factory.createConstant(index),
|
||||
ARRAYVALUE_CONSTANT);
|
||||
public static PathMetadata<Integer> forArrayAccess(Path.PArray<?> parent, int index) {
|
||||
return new PathMetadata<Integer>(parent, factory.createConstant(index), ARRAYVALUE_CONSTANT);
|
||||
}
|
||||
|
||||
public static PathMetadata<Integer> forListAccess(Path.PCollection<?> parent,
|
||||
Expr<Integer> index) {
|
||||
public static PathMetadata<Integer> forListAccess(Path.PCollection<?> parent, Expr<Integer> index) {
|
||||
return new PathMetadata<Integer>(parent, index, LISTVALUE);
|
||||
}
|
||||
|
||||
public static PathMetadata<Integer> forListAccess(Path.PCollection<?> parent,
|
||||
int index) {
|
||||
return new PathMetadata<Integer>(parent, factory.createConstant(index),
|
||||
LISTVALUE_CONSTANT);
|
||||
public static PathMetadata<Integer> forListAccess(Path.PCollection<?> parent, int index) {
|
||||
return new PathMetadata<Integer>(parent, factory.createConstant(index),LISTVALUE_CONSTANT);
|
||||
}
|
||||
|
||||
public static <KT> PathMetadata<KT> forMapAccess(Path.PMap<?, ?> parent,
|
||||
Expr<KT> key) {
|
||||
public static <KT> PathMetadata<KT> forMapAccess(Path.PMap<?, ?> parent, Expr<KT> key) {
|
||||
return new PathMetadata<KT>(parent, key, MAPVALUE);
|
||||
}
|
||||
|
||||
public static <KT> PathMetadata<KT> forMapAccess(Path.PMap<?, ?> parent,
|
||||
KT key) {
|
||||
public static <KT> PathMetadata<KT> forMapAccess(Path.PMap<?, ?> parent, KT key) {
|
||||
return new PathMetadata<KT>(parent, factory.createConstant(key), MAPVALUE_CONSTANT);
|
||||
}
|
||||
|
||||
public static PathMetadata<String> forProperty(Path<?> parent,
|
||||
String property) {
|
||||
public static PathMetadata<String> forProperty(Path<?> parent, String property) {
|
||||
return new PathMetadata<String>(parent, factory.createConstant(property), PROPERTY);
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,16 @@
|
||||
package com.mysema.query.grammar.types;
|
||||
|
||||
import com.mysema.query.grammar.Ops.Op;
|
||||
import com.mysema.query.grammar.types.Expr.EBoolean;
|
||||
import com.mysema.query.grammar.types.Expr.EComparable;
|
||||
import com.mysema.query.grammar.types.Expr.EConstant;
|
||||
import com.mysema.query.grammar.types.Expr.ENumber;
|
||||
import com.mysema.query.grammar.types.Expr.EString;
|
||||
import com.mysema.query.grammar.types.Operation.OBoolean;
|
||||
import com.mysema.query.grammar.types.Operation.OComparable;
|
||||
import com.mysema.query.grammar.types.Operation.ONumber;
|
||||
import com.mysema.query.grammar.types.Operation.OString;
|
||||
import com.mysema.query.grammar.types.Operation.OStringArray;
|
||||
import com.mysema.query.util.Assert;
|
||||
|
||||
/**
|
||||
@ -14,32 +24,32 @@ import com.mysema.query.util.Assert;
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SimpleExprFactory {
|
||||
public class SimpleExprFactory implements ExprFactory{
|
||||
|
||||
public Expr.EBoolean createBoolean(Op<Boolean> operator, Expr<?>... args) {
|
||||
return new Operation.OBoolean(Assert.notNull(operator), Assert.notNull(args));
|
||||
public EBoolean createBoolean(Op<Boolean> operator, Expr<?>... args) {
|
||||
return new OBoolean(Assert.notNull(operator), Assert.notNull(args));
|
||||
}
|
||||
|
||||
public <OpType, RT extends Comparable<? super RT>> Expr.EComparable<RT> createComparable(Class<RT> type, Op<OpType> operator, Expr<?>... args) {
|
||||
return new Operation.OComparable<OpType,RT>(type, Assert.notNull(operator), Assert.notNull(args));
|
||||
public <OpType, RT extends Comparable<? super RT>> EComparable<RT> createComparable(Class<RT> type, Op<OpType> operator, Expr<?>... args) {
|
||||
return new OComparable<OpType,RT>(type, Assert.notNull(operator), Assert.notNull(args));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <A> Expr<A> createConstant(A obj) {
|
||||
if (obj instanceof Expr) return (Expr<A>) obj;
|
||||
return new Expr.EConstant<A>(Assert.notNull(obj));
|
||||
return new EConstant<A>(Assert.notNull(obj));
|
||||
}
|
||||
|
||||
public <OpType extends Number,D extends Number & Comparable<? super D>> Expr.ENumber<D> createNumber(Class<? extends D> type, Op<OpType> operator, Expr<?>... args) {
|
||||
return new Operation.ONumber<OpType,D>(type, Assert.notNull(operator), Assert.notNull(args));
|
||||
public <OpType extends Number,D extends Number & Comparable<? super D>> ENumber<D> createNumber(Class<? extends D> type, Op<OpType> operator, Expr<?>... args) {
|
||||
return new ONumber<OpType,D>(type, Assert.notNull(operator), Assert.notNull(args));
|
||||
}
|
||||
|
||||
public Expr.EString createString(Op<String> operator, Expr<?>... args) {
|
||||
return new Operation.OString(Assert.notNull(operator), Assert.notNull(args));
|
||||
public EString createString(Op<String> operator, Expr<?>... args) {
|
||||
return new OString(Assert.notNull(operator), Assert.notNull(args));
|
||||
}
|
||||
|
||||
public Expr<String[]> createStringArray(Op<String> operator, Expr<?>... args) {
|
||||
return new Operation.OStringArray(Assert.notNull(operator), Assert.notNull(args));
|
||||
return new OStringArray(Assert.notNull(operator), Assert.notNull(args));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user