From c157203d24407bb2425f8b017fd5cd6fd0efc70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Westk=C3=A4mper?= Date: Wed, 27 May 2009 09:04:10 +0000 Subject: [PATCH] moved PathType to top level --- querydsl-apt/pom.xml | 2 +- querydsl-collections/pom.xml | 2 +- .../query/collections/JavaPatterns.java | 14 +++--- .../collections/eval/JavaSerializer.java | 12 ++--- querydsl-core/pom.xml | 2 +- .../query/serialization/BaseSerializer.java | 15 ++---- .../serialization/OperationPatterns.java | 12 ++--- .../mysema/query/types/path/PathMetadata.java | 49 +++---------------- .../com/mysema/query/types/path/PathType.java | 35 +++++++++++++ querydsl-hql/pom.xml | 2 +- .../com/mysema/query/hql/HQLPatterns.java | 12 ++--- .../com/mysema/query/hql/HQLSerializer.java | 11 +---- querydsl-jdoql/pom.xml | 2 +- .../com/mysema/query/jdoql/JDOQLPatterns.java | 15 +++--- querydsl-root/pom.xml | 2 +- 15 files changed, 86 insertions(+), 101 deletions(-) create mode 100644 querydsl-core/src/main/java/com/mysema/query/types/path/PathType.java diff --git a/querydsl-apt/pom.xml b/querydsl-apt/pom.xml index cd64ad8e6..59477b75b 100644 --- a/querydsl-apt/pom.xml +++ b/querydsl-apt/pom.xml @@ -6,7 +6,7 @@ com.mysema.querydsl querydsl-root - 0.3.8-SNAPSHOT + 0.3.9-SNAPSHOT com.mysema.querydsl diff --git a/querydsl-collections/pom.xml b/querydsl-collections/pom.xml index e0dd28983..e729bc5a5 100644 --- a/querydsl-collections/pom.xml +++ b/querydsl-collections/pom.xml @@ -6,7 +6,7 @@ com.mysema.querydsl querydsl-root - 0.3.8-SNAPSHOT + 0.3.9-SNAPSHOT com.mysema.querydsl diff --git a/querydsl-collections/src/main/java/com/mysema/query/collections/JavaPatterns.java b/querydsl-collections/src/main/java/com/mysema/query/collections/JavaPatterns.java index ce8502709..a2b3362d7 100644 --- a/querydsl-collections/src/main/java/com/mysema/query/collections/JavaPatterns.java +++ b/querydsl-collections/src/main/java/com/mysema/query/collections/JavaPatterns.java @@ -12,7 +12,7 @@ import com.mysema.query.serialization.OperationPatterns; import com.mysema.query.types.operation.Operator; import com.mysema.query.types.operation.Ops; import com.mysema.query.types.path.PathMetadata; -import com.mysema.query.types.path.PathMetadata.PathType; +import com.mysema.query.types.path.PathType; /** * JavaOps extends OperationPatterns to add Java syntax specific operation @@ -96,18 +96,18 @@ public class JavaPatterns extends OperationPatterns { add(Ops.MOD, "%s %% %s"); // path types - for (PathType type : new PathType[] { PathMetadata.LISTVALUE_CONSTANT }) { + for (PathType type : new PathType[] { PathType.LISTVALUE_CONSTANT }) { add(type, "%s.get(%s.intValue())"); } // path types - for (PathType type : new PathType[] { PathMetadata.LISTVALUE, - PathMetadata.LISTVALUE_CONSTANT, PathMetadata.MAPVALUE, - PathMetadata.MAPVALUE_CONSTANT }) { + for (PathType type : new PathType[] { PathType.LISTVALUE, + PathType.LISTVALUE_CONSTANT, PathType.MAPVALUE, + PathType.MAPVALUE_CONSTANT }) { add(type, "%s.get(%s)"); } - add(PathMetadata.ARRAYVALUE, "%s[%s]"); - add(PathMetadata.ARRAYVALUE_CONSTANT, "%s[%s.intValue()]"); + add(PathType.ARRAYVALUE, "%s[%s]"); + add(PathType.ARRAYVALUE_CONSTANT, "%s[%s.intValue()]"); } public static > boolean between(A a, A b, A c) { diff --git a/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JavaSerializer.java b/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JavaSerializer.java index 0311d8e16..63c4f9666 100644 --- a/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JavaSerializer.java +++ b/querydsl-collections/src/main/java/com/mysema/query/collections/eval/JavaSerializer.java @@ -5,10 +5,6 @@ */ package com.mysema.query.collections.eval; -import static com.mysema.query.types.path.PathMetadata.LISTVALUE_CONSTANT; -import static com.mysema.query.types.path.PathMetadata.PROPERTY; -import static com.mysema.query.types.path.PathMetadata.VARIABLE; - import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; @@ -29,7 +25,7 @@ import com.mysema.query.types.expr.Expr; import com.mysema.query.types.operation.Operator; import com.mysema.query.types.operation.Ops; import com.mysema.query.types.path.Path; -import com.mysema.query.types.path.PathMetadata.PathType; +import com.mysema.query.types.path.PathType; /** * JavaSerializer is a Serializer implementation for the Java language @@ -136,9 +132,9 @@ public class JavaSerializer extends BaseSerializer { parentAsString = toString((Expr) path.getMetadata().getParent(), false); } - if (pathType == VARIABLE) { + if (pathType == PathType.VARIABLE) { exprAsString = path.getMetadata().getExpression().toString(); - } else if (pathType == PROPERTY) { + } else if (pathType == PathType.PROPERTY) { String prefix = "get"; if (((Expr) path).getType() != null && ((Expr) path).getType().equals(Boolean.class)) { @@ -148,7 +144,7 @@ public class JavaSerializer extends BaseSerializer { + StringUtils.capitalize(path.getMetadata().getExpression() .toString()) + "()"; - } else if (pathType == LISTVALUE_CONSTANT) { + } else if (pathType == PathType.LISTVALUE_CONSTANT) { exprAsString = path.getMetadata().getExpression().toString(); } else if (path.getMetadata().getExpression() != null) { diff --git a/querydsl-core/pom.xml b/querydsl-core/pom.xml index cb8802287..367798755 100644 --- a/querydsl-core/pom.xml +++ b/querydsl-core/pom.xml @@ -6,7 +6,7 @@ com.mysema.querydsl querydsl-root - 0.3.8-SNAPSHOT + 0.3.9-SNAPSHOT com.mysema.querydsl diff --git a/querydsl-core/src/main/java/com/mysema/query/serialization/BaseSerializer.java b/querydsl-core/src/main/java/com/mysema/query/serialization/BaseSerializer.java index 80f0b674f..fe5a08e98 100644 --- a/querydsl-core/src/main/java/com/mysema/query/serialization/BaseSerializer.java +++ b/querydsl-core/src/main/java/com/mysema/query/serialization/BaseSerializer.java @@ -5,11 +5,6 @@ */ package com.mysema.query.serialization; -import static com.mysema.query.types.path.PathMetadata.ARRAYVALUE_CONSTANT; -import static com.mysema.query.types.path.PathMetadata.LISTVALUE_CONSTANT; -import static com.mysema.query.types.path.PathMetadata.PROPERTY; -import static com.mysema.query.types.path.PathMetadata.VARIABLE; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -23,10 +18,10 @@ import com.mysema.query.types.expr.EArrayConstructor; import com.mysema.query.types.expr.EConstant; import com.mysema.query.types.expr.EConstructor; import com.mysema.query.types.expr.Expr; -import com.mysema.query.types.operation.Operator; import com.mysema.query.types.operation.Operation; +import com.mysema.query.types.operation.Operator; import com.mysema.query.types.path.Path; -import com.mysema.query.types.path.PathMetadata.PathType; +import com.mysema.query.types.path.PathType; import com.mysema.query.types.quant.Quant; /** @@ -149,9 +144,9 @@ public abstract class BaseSerializer> parentAsString = toString((Expr) path.getMetadata().getParent(), false); } - if (pathType == PROPERTY || pathType == VARIABLE - || pathType == LISTVALUE_CONSTANT - || pathType == ARRAYVALUE_CONSTANT) { + if (pathType == PathType.PROPERTY || pathType == PathType.VARIABLE + || pathType == PathType.LISTVALUE_CONSTANT + || pathType == PathType.ARRAYVALUE_CONSTANT) { exprAsString = path.getMetadata().getExpression().toString(); } else if (path.getMetadata().getExpression() != null) { exprAsString = toString(path.getMetadata().getExpression(), false); diff --git a/querydsl-core/src/main/java/com/mysema/query/serialization/OperationPatterns.java b/querydsl-core/src/main/java/com/mysema/query/serialization/OperationPatterns.java index 96c8a1c11..2ff9a5f24 100644 --- a/querydsl-core/src/main/java/com/mysema/query/serialization/OperationPatterns.java +++ b/querydsl-core/src/main/java/com/mysema/query/serialization/OperationPatterns.java @@ -12,7 +12,7 @@ import com.mysema.query.types.operation.Operator; import com.mysema.query.types.operation.Ops; import com.mysema.query.types.operation.Ops.OpNumberAgg; import com.mysema.query.types.path.PathMetadata; -import com.mysema.query.types.path.PathMetadata.PathType; +import com.mysema.query.types.path.PathType; /** * OperationPatterns provides operator patterns for SQL/HQL serialization @@ -153,13 +153,13 @@ public class OperationPatterns { add(Ops.OpString.SPACE, "space(%s)"); // path types - for (PathType type : new PathType[] { PathMetadata.LISTVALUE, - PathMetadata.LISTVALUE_CONSTANT, PathMetadata.MAPVALUE, - PathMetadata.MAPVALUE_CONSTANT }) { + for (PathType type : new PathType[] { PathType.LISTVALUE, + PathType.LISTVALUE_CONSTANT, PathType.MAPVALUE, + PathType.MAPVALUE_CONSTANT }) { add(type, "%s.get(%s)"); } - add(PathMetadata.PROPERTY, "%s.%s"); - add(PathMetadata.VARIABLE, "%s"); + add(PathType.PROPERTY, "%s.%s"); + add(PathType.VARIABLE, "%s"); // numeric aggregates add(OpNumberAgg.AVG_AGG, "avg(%s)"); diff --git a/querydsl-core/src/main/java/com/mysema/query/types/path/PathMetadata.java b/querydsl-core/src/main/java/com/mysema/query/types/path/PathMetadata.java index 2f04f84b5..44571e7ce 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/path/PathMetadata.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/path/PathMetadata.java @@ -11,7 +11,6 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import com.mysema.query.types.ExprFactory; import com.mysema.query.types.SimpleExprFactory; import com.mysema.query.types.expr.Expr; -import com.mysema.query.types.operation.Operator; /** * PathMetadata provides metadata for Path expressions. @@ -21,70 +20,38 @@ import com.mysema.query.types.operation.Operator; */ public final class PathMetadata { - /** - * The Class PathType. - */ - public static class PathType extends Operator> { - private final String symbol; - - public PathType(String symbol) { - super(); - this.symbol = symbol; - } - - public String toString() { - return symbol; - } - } - private static ExprFactory factory = SimpleExprFactory.getInstance(); - public static final PathType ARRAYVALUE = new PathType("array value"); - - public static final PathType ARRAYVALUE_CONSTANT = new PathType("array value constant"); - - public static final PathType LISTVALUE = new PathType("list value"); - - public static final PathType LISTVALUE_CONSTANT = new PathType("list value constant"); - - public static final PathType MAPVALUE = new PathType("map value"); - - public static final PathType MAPVALUE_CONSTANT = new PathType("map value constant"); - - public static final PathType PROPERTY = new PathType("propery"); - - public static final PathType VARIABLE = new PathType("variable"); - public static PathMetadata forArrayAccess(PArray parent, Expr index) { - return new PathMetadata(parent, index, ARRAYVALUE); + return new PathMetadata(parent, index, PathType.ARRAYVALUE); } public static PathMetadata forArrayAccess(PArray parent, int index) { - return new PathMetadata(parent, factory.createConstant(index), ARRAYVALUE_CONSTANT); + return new PathMetadata(parent, factory.createConstant(index), PathType.ARRAYVALUE_CONSTANT); } public static PathMetadata forListAccess(PCollection parent, Expr index) { - return new PathMetadata(parent, index, LISTVALUE); + return new PathMetadata(parent, index, PathType.LISTVALUE); } public static PathMetadata forListAccess(PCollection parent, int index) { - return new PathMetadata(parent, factory.createConstant(index), LISTVALUE_CONSTANT); + return new PathMetadata(parent, factory.createConstant(index), PathType.LISTVALUE_CONSTANT); } public static PathMetadata forMapAccess(PMap parent, Expr key) { - return new PathMetadata(parent, key, MAPVALUE); + return new PathMetadata(parent, key, PathType.MAPVALUE); } public static PathMetadata forMapAccess(PMap parent, KT key) { - return new PathMetadata(parent, factory.createConstant(key), MAPVALUE_CONSTANT); + return new PathMetadata(parent, factory.createConstant(key), PathType.MAPVALUE_CONSTANT); } public static PathMetadata forProperty(Path parent, String property) { - return new PathMetadata(parent, factory.createConstant(property), PROPERTY); + return new PathMetadata(parent, factory.createConstant(property), PathType.PROPERTY); } public static PathMetadata forVariable(String variable) { - return new PathMetadata(null, factory.createConstant(variable),VARIABLE); + return new PathMetadata(null, factory.createConstant(variable), PathType.VARIABLE); } private final Expr expression; diff --git a/querydsl-core/src/main/java/com/mysema/query/types/path/PathType.java b/querydsl-core/src/main/java/com/mysema/query/types/path/PathType.java new file mode 100644 index 000000000..7d6a99b30 --- /dev/null +++ b/querydsl-core/src/main/java/com/mysema/query/types/path/PathType.java @@ -0,0 +1,35 @@ +package com.mysema.query.types.path; + +import com.mysema.query.types.operation.Operator; + +/** + * The Class PathType. + */ +public class PathType extends Operator> { + private final String symbol; + + public PathType(String symbol) { + super(); + this.symbol = symbol; + } + + public String toString() { + return symbol; + } + + public static final PathType ARRAYVALUE = new PathType("array value"); + + public static final PathType ARRAYVALUE_CONSTANT = new PathType("array value constant"); + + public static final PathType LISTVALUE = new PathType("list value"); + + public static final PathType LISTVALUE_CONSTANT = new PathType("list value constant"); + + public static final PathType MAPVALUE = new PathType("map value"); + + public static final PathType MAPVALUE_CONSTANT = new PathType("map value constant"); + + public static final PathType PROPERTY = new PathType("propery"); + + public static final PathType VARIABLE = new PathType("variable"); +} \ No newline at end of file diff --git a/querydsl-hql/pom.xml b/querydsl-hql/pom.xml index d82209bb2..c01273d25 100644 --- a/querydsl-hql/pom.xml +++ b/querydsl-hql/pom.xml @@ -6,7 +6,7 @@ com.mysema.querydsl querydsl-root - 0.3.8-SNAPSHOT + 0.3.9-SNAPSHOT com.mysema.querydsl diff --git a/querydsl-hql/src/main/java/com/mysema/query/hql/HQLPatterns.java b/querydsl-hql/src/main/java/com/mysema/query/hql/HQLPatterns.java index 87ede9877..6ba8f80af 100644 --- a/querydsl-hql/src/main/java/com/mysema/query/hql/HQLPatterns.java +++ b/querydsl-hql/src/main/java/com/mysema/query/hql/HQLPatterns.java @@ -14,7 +14,7 @@ import com.mysema.query.serialization.OperationPatterns; import com.mysema.query.types.operation.Operator; import com.mysema.query.types.operation.Ops; import com.mysema.query.types.path.PathMetadata; -import com.mysema.query.types.path.PathMetadata.PathType; +import com.mysema.query.types.path.PathType; /** * HqlOps extends OperationPatterns to provide operator patterns for HQL @@ -96,14 +96,14 @@ public class HQLPatterns extends OperationPatterns { add(OpQuant.NOTEXISTS, "not exists %s"); // path types - for (PathType type : new PathType[] { PathMetadata.LISTVALUE, - PathMetadata.LISTVALUE_CONSTANT, PathMetadata.MAPVALUE, - PathMetadata.MAPVALUE_CONSTANT }) { + for (PathType type : new PathType[] { PathType.LISTVALUE, + PathType.LISTVALUE_CONSTANT, PathType.MAPVALUE, + PathType.MAPVALUE_CONSTANT }) { add(type, "%s[%s]"); } - add(PathMetadata.PROPERTY, "%s.%s"); + add(PathType.PROPERTY, "%s.%s"); - add(PathMetadata.VARIABLE, "%s"); + add(PathType.VARIABLE, "%s"); // HQL types add(HqlPathType.MINELEMENT, "minelement(%s)"); diff --git a/querydsl-hql/src/main/java/com/mysema/query/hql/HQLSerializer.java b/querydsl-hql/src/main/java/com/mysema/query/hql/HQLSerializer.java index 27f0543f9..b6417f76c 100644 --- a/querydsl-hql/src/main/java/com/mysema/query/hql/HQLSerializer.java +++ b/querydsl-hql/src/main/java/com/mysema/query/hql/HQLSerializer.java @@ -5,10 +5,7 @@ */ package com.mysema.query.hql; -import static com.mysema.query.types.path.PathMetadata.PROPERTY; - import java.util.ArrayList; -import java.util.Collections; import java.util.List; import com.mysema.query.JoinExpression; @@ -28,11 +25,7 @@ import com.mysema.query.types.operation.Ops; import com.mysema.query.types.path.PCollection; import com.mysema.query.types.path.PEntity; import com.mysema.query.types.path.Path; -import com.mysema.query.types.quant.QBoolean; -import com.mysema.query.types.quant.QComparable; -import com.mysema.query.types.quant.QNumber; -import com.mysema.query.types.quant.QSimple; -import com.mysema.query.types.quant.Quant; +import com.mysema.query.types.path.PathType; /** * HqlSerializer serializes querydsl expressions into HQL syntax. @@ -184,7 +177,7 @@ public class HQLSerializer extends BaseSerializer { protected void visit(PCollection expr) { // only wrap a PathCollection, if it the pathType is PROPERTY boolean wrap = wrapElements - && expr.getMetadata().getPathType().equals(PROPERTY); + && expr.getMetadata().getPathType().equals(PathType.PROPERTY); if (wrap) { append("elements("); } diff --git a/querydsl-jdoql/pom.xml b/querydsl-jdoql/pom.xml index cac0770ab..5eea13dc8 100644 --- a/querydsl-jdoql/pom.xml +++ b/querydsl-jdoql/pom.xml @@ -6,7 +6,7 @@ com.mysema.querydsl querydsl-root - 0.3.8-SNAPSHOT + 0.3.9-SNAPSHOT com.mysema.querydsl diff --git a/querydsl-jdoql/src/main/java/com/mysema/query/jdoql/JDOQLPatterns.java b/querydsl-jdoql/src/main/java/com/mysema/query/jdoql/JDOQLPatterns.java index 23f481c81..2ed3445b8 100644 --- a/querydsl-jdoql/src/main/java/com/mysema/query/jdoql/JDOQLPatterns.java +++ b/querydsl-jdoql/src/main/java/com/mysema/query/jdoql/JDOQLPatterns.java @@ -10,8 +10,7 @@ import java.util.Collection; import com.mysema.query.serialization.OperationPatterns; import com.mysema.query.types.operation.Operator; import com.mysema.query.types.operation.Ops; -import com.mysema.query.types.path.PathMetadata; -import com.mysema.query.types.path.PathMetadata.PathType; +import com.mysema.query.types.path.PathType; /** * Operation patterns for JDOQL serialization @@ -76,14 +75,14 @@ public class JDOQLPatterns extends OperationPatterns { // path types - add(PathMetadata.VARIABLE, "%s"); - for (PathType type : new PathType[] { PathMetadata.LISTVALUE, - PathMetadata.LISTVALUE_CONSTANT, PathMetadata.MAPVALUE, - PathMetadata.MAPVALUE_CONSTANT }) { + add(PathType.VARIABLE, "%s"); + for (PathType type : new PathType[] { PathType.LISTVALUE, + PathType.LISTVALUE_CONSTANT, PathType.MAPVALUE, + PathType.MAPVALUE_CONSTANT }) { add(type, "%s.get(%s)"); } - add(PathMetadata.ARRAYVALUE, "%s[%s]"); - add(PathMetadata.ARRAYVALUE_CONSTANT, "%s[%s]"); + add(PathType.ARRAYVALUE, "%s[%s]"); + add(PathType.ARRAYVALUE_CONSTANT, "%s[%s]"); } /** diff --git a/querydsl-root/pom.xml b/querydsl-root/pom.xml index 4d383af7a..02a3c1a18 100644 --- a/querydsl-root/pom.xml +++ b/querydsl-root/pom.xml @@ -7,7 +7,7 @@ 4.0.0 com.mysema.querydsl querydsl-root - 0.3.8-SNAPSHOT + 0.3.9-SNAPSHOT Querydsl parent project for querydsl modules http://source.mysema.com/display/querydsl