#145 added DslExpression as common base type for scalar and non-scalar expressions

This commit is contained in:
Timo Westkämper 2012-05-13 19:34:48 +03:00
parent 522d896e17
commit daa2b05580
19 changed files with 440 additions and 53 deletions

View File

@ -43,6 +43,10 @@ public class CollectionTest {
Collection collection2;
Collection<Collection<Person>> collectionOfCOllection;
Collection<Set<String>> collectionOfSet;
Set<?> set1;
Set set2;

View File

@ -22,6 +22,7 @@ import com.mysema.query.types.NullExpression;
import com.mysema.query.types.Operator;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathImpl;
import com.mysema.query.types.PathMetadataFactory;
import com.mysema.query.types.expr.BooleanExpression;
import com.mysema.query.types.expr.BooleanOperation;
@ -32,6 +33,8 @@ import com.mysema.query.types.expr.DateExpression;
import com.mysema.query.types.expr.DateOperation;
import com.mysema.query.types.expr.DateTimeExpression;
import com.mysema.query.types.expr.DateTimeOperation;
import com.mysema.query.types.expr.DslExpression;
import com.mysema.query.types.expr.DslOperation;
import com.mysema.query.types.expr.NumberExpression;
import com.mysema.query.types.expr.NumberOperation;
import com.mysema.query.types.expr.SimpleExpression;
@ -44,13 +47,16 @@ import com.mysema.query.types.path.BooleanPath;
import com.mysema.query.types.path.ComparablePath;
import com.mysema.query.types.path.DatePath;
import com.mysema.query.types.path.DateTimePath;
import com.mysema.query.types.path.DslPath;
import com.mysema.query.types.path.NumberPath;
import com.mysema.query.types.path.SimplePath;
import com.mysema.query.types.path.StringPath;
import com.mysema.query.types.path.TimePath;
import com.mysema.query.types.query.ExtendedSubQueryExpression;
import com.mysema.query.types.query.SimpleSubQuery;
import com.mysema.query.types.template.BooleanTemplate;
import com.mysema.query.types.template.ComparableTemplate;
import com.mysema.query.types.template.DslTemplate;
import com.mysema.query.types.template.NumberTemplate;
import com.mysema.query.types.template.SimpleTemplate;
import com.mysema.query.types.template.StringTemplate;
@ -71,6 +77,10 @@ public final class Expressions {
return SimpleOperation.create((Class<D>)alias.getType(), Ops.ALIAS, source, alias);
}
}
public static <D> SimpleExpression<D> as(Expression<D> source, String alias) {
return as(source, new PathImpl<D>(source.getType(), alias));
}
@Nullable
public static BooleanExpression allOf(BooleanExpression... exprs) {
@ -99,6 +109,10 @@ public final class Expressions {
return SimpleTemplate.create(cl, template, args);
}
public static <T> DslExpression<T> dslTemplate(Class<T> cl, String template, Expression<?>... args) {
return DslTemplate.create(cl, template, args);
}
public static <T extends Comparable<?>> ComparableExpression<T> comparableTemplate(Class<T> cl,
String template, Expression<?>... args) {
return ComparableTemplate.create(cl, template, args);
@ -117,7 +131,7 @@ public final class Expressions {
return BooleanTemplate.create(template, args);
}
public static <T> SimpleExpression<T> subQuery(Class<T> type, QueryMetadata metadata) {
public static <T> ExtendedSubQueryExpression<T> subQuery(Class<T> type, QueryMetadata metadata) {
return new SimpleSubQuery<T>(type, metadata);
}
@ -130,6 +144,11 @@ public final class Expressions {
return SimpleOperation.create(type, operator, args);
}
public static <T> DslExpression<T> dslOperation(Class<T> type, Operator<? super T> operator,
Expression<?>... args) {
return DslOperation.create(type, operator, args);
}
public static BooleanExpression booleanOperation(Operator<Boolean> operation, Expression<?>... args) {
return predicate(operation, args);
}
@ -166,10 +185,18 @@ public final class Expressions {
public static <T> SimplePath<T> path(Class<T> type, String variable) {
return new SimplePath<T>(type, PathMetadataFactory.forVariable(variable));
}
public static <T> SimplePath<T> path(Class<T> type, Path<?> parent, String property) {
return new SimplePath<T>(type, PathMetadataFactory.forProperty(parent, property));
}
}
public static <T> DslPath<T> dslPath(Class<T> type, String variable) {
return new DslPath<T>(type, PathMetadataFactory.forVariable(variable));
}
public static <T> DslPath<T> dslPath(Class<T> type, Path<?> parent, String property) {
return new DslPath<T>(type, PathMetadataFactory.forProperty(parent, property));
}
public static <T extends Comparable<?>> ComparablePath<T> comparablePath(Class<T> type,
String variable) {

View File

@ -30,7 +30,7 @@ import com.mysema.query.types.Ops;
* @param <T> expression type
* @param <E> collection element type
*/
public abstract class CollectionExpressionBase<T extends Collection<E>, E> extends SimpleExpression<T> implements CollectionExpression<T, E> {
public abstract class CollectionExpressionBase<T extends Collection<E>, E> extends DslExpression<T> implements CollectionExpression<T, E> {
private static final long serialVersionUID = 691230660037162054L;
@ -53,6 +53,8 @@ public abstract class CollectionExpressionBase<T extends Collection<E>, E> exten
}
public abstract Class<E> getElementType();
public final BooleanExpression isEmpty() {
if (empty == null) {

View File

@ -0,0 +1,55 @@
/*
* Copyright 2012, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.types.expr;
import com.mysema.query.types.ExpressionBase;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathImpl;
/**
* DslExpression is the base class for DSL expressions, but SimpleExpression is the base class
* for scalar Expressions
*
* @author tiwe
*
*/
public abstract class DslExpression<T> extends ExpressionBase<T>{
private static final long serialVersionUID = -3383063447710753290L;
public DslExpression(Class<? extends T> type) {
super(type);
}
/**
* Create an alias for the expression
*
* @return
*/
@SuppressWarnings("unchecked")
public DslExpression<T> as(Path<T> alias) {
return DslOperation.create((Class<T>)getType(),Ops.ALIAS, this, alias);
}
/**
* Create an alias for the expression
*
* @return
*/
public DslExpression<T> as(String alias) {
return as(new PathImpl<T>(getType(), alias));
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2011, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.types.expr;
import java.util.Arrays;
import java.util.List;
import com.mysema.query.types.Expression;
import com.mysema.query.types.Operation;
import com.mysema.query.types.OperationImpl;
import com.mysema.query.types.Operator;
import com.mysema.query.types.Visitor;
/**
* DslOperation represents a simple operation expression
*
* @author tiwe
*
* @param <T> expression type
*/
public class DslOperation<T> extends DslExpression<T> implements Operation<T> {
private static final long serialVersionUID = -285668548371034230L;
/**
* Factory method
*
* @param <D>
* @param type
* @param op
* @param args
* @return
*/
public static <D> DslExpression<D> create(Class<D> type, Operator<? super D> op, Expression<?>... args) {
return new DslOperation<D>(type, op, args);
}
private final Operation< T> opMixin;
protected DslOperation(Class<T> type, Operator<? super T> op, Expression<?>... args) {
this(type, op, Arrays.asList(args));
}
protected DslOperation(Class<T> type, Operator<? super T> op, List<Expression<?>> args) {
super(type);
this.opMixin = new OperationImpl<T>(type, op, args);
}
@Override
public <R,C> R accept(Visitor<R,C> v, C context) {
return v.visit(this, context);
}
@Override
public Expression<?> getArg(int index) {
return opMixin.getArg(index);
}
@Override
public List<Expression<?>> getArgs() {
return opMixin.getArgs();
}
@Override
public Operator<? super T> getOperator() {
return opMixin.getOperator();
}
@Override
public boolean equals(Object o) {
return opMixin.equals(o);
}
@Override
public int hashCode() {
return getType().hashCode();
}
}

View File

@ -30,7 +30,7 @@ import com.mysema.query.types.Ops;
* @param <K> key type
* @param <V> value type
*/
public abstract class MapExpressionBase<K, V, Q extends SimpleExpression<? super V>> extends SimpleExpression<Map<K,V>> implements MapExpression<K,V> {
public abstract class MapExpressionBase<K, V, Q extends SimpleExpression<? super V>> extends DslExpression<Map<K,V>> implements MapExpression<K,V> {
private static final long serialVersionUID = 2856001983312366841L;
@ -43,7 +43,7 @@ public abstract class MapExpressionBase<K, V, Q extends SimpleExpression<? super
public MapExpressionBase(Class<? extends Map<K, V>> type) {
super(type);
}
public final BooleanExpression contains(K key, V value) {
return get(key).eq(value);
}

View File

@ -22,7 +22,6 @@ import javax.annotation.Nullable;
import com.mysema.query.types.CollectionExpression;
import com.mysema.query.types.ConstantImpl;
import com.mysema.query.types.Expression;
import com.mysema.query.types.ExpressionBase;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathImpl;
@ -34,7 +33,7 @@ import com.mysema.query.types.PathImpl;
*
* @param <T> expression type
*/
public abstract class SimpleExpression<T> extends ExpressionBase<T> {
public abstract class SimpleExpression<T> extends DslExpression<T> {
private static final long serialVersionUID = -4405387187738167105L;
@ -57,6 +56,26 @@ public abstract class SimpleExpression<T> extends ExpressionBase<T> {
|| Character.class.equals(type);
}
/**
* Create an alias for the expression
*
* @return
*/
@SuppressWarnings("unchecked")
public SimpleExpression<T> as(Path<T> alias) {
return SimpleOperation.create((Class<T>)getType(),Ops.ALIAS, this, alias);
}
/**
* Create an alias for the expression
*
* @return
*/
public SimpleExpression<T> as(String alias) {
return as(new PathImpl<T>(getType(), alias));
}
/**
* Create a <code>this is not null</code> expression
*
@ -81,25 +100,6 @@ public abstract class SimpleExpression<T> extends ExpressionBase<T> {
return isnull;
}
/**
* Create an alias for the expression
*
* @return
*/
@SuppressWarnings("unchecked")
public SimpleExpression<T> as(Path<T> alias) {
return SimpleOperation.create((Class<T>)getType(),Ops.ALIAS, this, alias);
}
/**
* Create an alias for the expression
*
* @return
*/
public SimpleExpression<T> as(String alias) {
return as(new PathImpl<T>(getType(), alias));
}
/**
* Get the <code>count(this)</code> expression
*

View File

@ -0,0 +1,80 @@
/*
* Copyright 2011, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.types.path;
import java.lang.reflect.AnnotatedElement;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathImpl;
import com.mysema.query.types.PathMetadata;
import com.mysema.query.types.PathMetadataFactory;
import com.mysema.query.types.Visitor;
import com.mysema.query.types.expr.DslExpression;
/**
* DslPath represents simple paths
*
* @author tiwe
*
* @param <T> expression type
*/
public class DslPath<T> extends DslExpression<T> implements Path<T> {
private static final long serialVersionUID = 3088836955328191852L;
private final Path<T> pathMixin;
public DslPath(Class<? extends T> type, Path<?> parent, String property) {
this(type, PathMetadataFactory.forProperty(parent, property));
}
public DslPath(Class<? extends T> type, PathMetadata<?> metadata) {
super(type);
this.pathMixin = new PathImpl<T>(type, metadata);
}
public DslPath(Class<? extends T> type, String var) {
this(type, PathMetadataFactory.forVariable(var));
}
@Override
public <R,C> R accept(Visitor<R,C> v, C context) {
return v.visit(this, context);
}
@Override
public boolean equals(Object o) {
return pathMixin.equals(o);
}
@Override
public PathMetadata<?> getMetadata() {
return pathMixin.getMetadata();
}
@Override
public Path<?> getRoot() {
return pathMixin.getRoot();
}
@Override
public int hashCode() {
return pathMixin.hashCode();
}
@Override
public AnnotatedElement getAnnotatedElement() {
return pathMixin.getAnnotatedElement();
}
}

View File

@ -74,7 +74,7 @@ public final class ListSubQuery<T> extends CollectionExpressionBase<List<T>,T> i
return subQueryMixin.equals(o);
}
@Override
//@Override
public NumberExpression<Long> count(){
if (count == null) {
count = count(Ops.AggOps.COUNT_AGG);
@ -82,7 +82,7 @@ public final class ListSubQuery<T> extends CollectionExpressionBase<List<T>,T> i
return count;
}
@Override
//@Override
public NumberExpression<Long> countDistinct(){
if (countDistinct == null) {
countDistinct = count(Ops.AggOps.COUNT_DISTINCT_AGG);

View File

@ -22,7 +22,7 @@ import com.mysema.query.types.SubQueryExpressionImpl;
import com.mysema.query.types.Visitor;
import com.mysema.query.types.expr.BooleanExpression;
import com.mysema.query.types.expr.BooleanOperation;
import com.mysema.query.types.expr.SimpleExpression;
import com.mysema.query.types.expr.DslExpression;
/**
* Object typed single result subquery
@ -31,7 +31,7 @@ import com.mysema.query.types.expr.SimpleExpression;
*
* @param <T> expression type
*/
public final class SimpleSubQuery<T> extends SimpleExpression<T> implements ExtendedSubQueryExpression<T>{
public final class SimpleSubQuery<T> extends DslExpression<T> implements ExtendedSubQueryExpression<T>{
private static final long serialVersionUID = -64156984110154969L;

View File

@ -0,0 +1,83 @@
/*
* Copyright 2011, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.types.template;
import java.util.Arrays;
import java.util.List;
import com.mysema.query.types.Expression;
import com.mysema.query.types.Template;
import com.mysema.query.types.TemplateExpression;
import com.mysema.query.types.TemplateExpressionImpl;
import com.mysema.query.types.TemplateFactory;
import com.mysema.query.types.Visitor;
import com.mysema.query.types.expr.DslExpression;
/**
* DslTemplate defines custom simple expressions
*
* @author tiwe
*
* @param <T> expression type
*/
public class DslTemplate<T> extends DslExpression<T> implements TemplateExpression<T> {
private static final long serialVersionUID = -4697578522909045745L;
public static <T> DslExpression<T> create(Class<? extends T> type, String template, Expression<?>... args) {
return new DslTemplate<T>(type, TemplateFactory.DEFAULT.create(template), Arrays.<Expression<?>>asList(args));
}
public static <T> DslExpression<T> create(Class<? extends T> type, Template template, Expression<?>... args) {
return new DslTemplate<T>(type, template, Arrays.<Expression<?>>asList(args));
}
private final TemplateExpression<T> templateMixin;
public DslTemplate(Class<? extends T> type, Template template, List<Expression<?>> args) {
super(type);
templateMixin = new TemplateExpressionImpl<T>(type, template, args);
}
@Override
public <R,C> R accept(Visitor<R,C> v, C context) {
return v.visit(this, context);
}
@Override
public Expression<?> getArg(int index) {
return templateMixin.getArg(index);
}
@Override
public List<Expression<?>> getArgs() {
return templateMixin.getArgs();
}
@Override
public Template getTemplate() {
return templateMixin.getTemplate();
}
@Override
public boolean equals(Object o) {
return templateMixin.equals(o);
}
@Override
public int hashCode() {
return getType().hashCode();
}
}

View File

@ -28,6 +28,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.mysema.query.types.expr.DslExpression;
import com.mysema.query.types.expr.SimpleExpression;
public class SignatureTest {
@ -60,6 +61,7 @@ public class SignatureTest {
if (!skippedMethods.contains(m.getName())
&& Modifier.isPublic(m.getModifiers())
&& Expression.class.isAssignableFrom(m.getReturnType())
&& !DslExpression.class.isAssignableFrom(m.getReturnType())
&& !SimpleExpression.class.isAssignableFrom(m.getReturnType())){
errors.add(cl.getSimpleName()+"."+m.getName() + " has illegal return type");
}

View File

@ -24,11 +24,27 @@ import java.util.List;
import org.junit.Test;
import com.mysema.query.support.Expressions;
import com.mysema.query.types.Expression;
import com.mysema.query.types.OperationImpl;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathImpl;
import com.mysema.query.types.path.*;
import com.mysema.query.types.path.ArrayPath;
import com.mysema.query.types.path.BeanPath;
import com.mysema.query.types.path.BooleanPath;
import com.mysema.query.types.path.CollectionPath;
import com.mysema.query.types.path.ComparablePath;
import com.mysema.query.types.path.DatePath;
import com.mysema.query.types.path.DateTimePath;
import com.mysema.query.types.path.EnumPath;
import com.mysema.query.types.path.ListPath;
import com.mysema.query.types.path.MapPath;
import com.mysema.query.types.path.NumberPath;
import com.mysema.query.types.path.SetPath;
import com.mysema.query.types.path.SimplePath;
import com.mysema.query.types.path.StringPath;
import com.mysema.query.types.path.TimePath;
public class SimpleExpressionTest {
@ -66,7 +82,7 @@ public class SimpleExpressionTest {
@SuppressWarnings("unchecked")
@Test
public void Various(){
List<SimpleExpression<?>> paths = new ArrayList<SimpleExpression<?>>();
List<DslExpression<?>> paths = new ArrayList<DslExpression<?>>();
paths.add(new ArrayPath(String[].class, "p"));
paths.add(new BeanPath(Object.class, "p"));
paths.add(new BooleanPath("p"));
@ -83,7 +99,7 @@ public class SimpleExpressionTest {
paths.add(new StringPath("p"));
paths.add(new TimePath(Time.class,"p"));
for (SimpleExpression<?> expr : paths){
for (DslExpression<?> expr : paths){
Path o = new PathImpl(expr.getType(), "o");
assertEquals(OperationImpl.create(expr.getType(), Ops.ALIAS, expr, o), expr.as("o"));
Path p = new PathImpl(expr.getType(), "p");

View File

@ -369,7 +369,7 @@ public abstract class AbstractStandardTest {
@Test
@Ignore
public void In6() {
query().from(cat).where(cat.kittens.in(savedCats)).count();
//query().from(cat).where(cat.kittens.in(savedCats)).count();
}
@Test
@ -381,13 +381,13 @@ public abstract class AbstractStandardTest {
public void Collection_Predicates() {
ListPath<Cat, QCat> path = cat.kittens;
List<Predicate> predicates = Arrays.<Predicate>asList(
//path.eq(savedCats),
//path.in(savedCats),
//path.isNotNull(),
//path.isNull(),
//path.ne(savedCats),
//path.notIn(savedCats)
//path.when(other)
// path.eq(savedCats),
// path.in(savedCats),
// path.isNotNull(),
// path.isNull(),
// path.ne(savedCats),
// path.notIn(savedCats)
// path.when(other)
);
for (Predicate pred : predicates) {
System.err.println(pred);
@ -399,8 +399,8 @@ public abstract class AbstractStandardTest {
public void Collection_Projections() {
ListPath<Cat, QCat> path = cat.kittens;
List<Expression<?>> projections = Arrays.<Expression<?>>asList(
//path.count(),
//path.countDistinct()
// path.count(),
// path.countDistinct()
);
for (Expression<?> proj : projections) {
System.err.println(proj);

View File

@ -361,8 +361,8 @@ public class MongodbQueryTest {
i.setCtds(Arrays.asList(ObjectId.get(), ObjectId.get(), ObjectId.get()));
ds.save(i);
assertTrue(where(item, item.ctds.in(i.getCtds())).count() > 0);
assertTrue(where(item, item.ctds.in(Arrays.asList(ObjectId.get(), ObjectId.get()))).count() == 0);
assertTrue(where(item, item.ctds.any().in(i.getCtds())).count() > 0);
assertTrue(where(item, item.ctds.any().in(Arrays.asList(ObjectId.get(), ObjectId.get()))).count() == 0);
}
//TODO

View File

@ -37,11 +37,19 @@ object Constants {
}
trait SimpleExpression[T] extends Expression[T] {
def as(right: Path[T]): SimpleExpression[T] = simple(getType, ALIAS.asInstanceOf[Operator[T]], this, right)
trait DslExpression[T] extends Expression[T] {
def as(alias: String): SimpleExpression[T] = as(new PathImpl[T](getType, alias))
def as(right: Path[T]): DslExpression[T] = dsl(getType, ALIAS.asInstanceOf[Operator[T]], this, right)
def as(alias: String): DslExpression[T] = as(new PathImpl[T](getType, alias))
}
trait SimpleExpression[T] extends DslExpression[T] {
override def as(right: Path[T]): SimpleExpression[T] = simple(getType, ALIAS.asInstanceOf[Operator[T]], this, right)
override def as(alias: String): SimpleExpression[T] = as(new PathImpl[T](getType, alias))
def eq(right: T): BooleanExpression = eq(constant(right))
@ -87,14 +95,14 @@ trait SimpleExpression[T] extends Expression[T] {
}
trait ArrayExpression[T <: Array[_]] extends SimpleExpression[T] {
trait ArrayExpression[T <: Array[_]] extends DslExpression[T] {
lazy val size = number[Integer](classOf[Integer], Ops.ARRAY_SIZE, this)
}
trait CollectionExpressionBase[T <: Collection[C], C, Q <: Expression[_ >: C]]
extends SimpleExpression[T] with com.mysema.query.types.CollectionExpression[T,C] {
extends DslExpression[T] with com.mysema.query.types.CollectionExpression[T,C] {
lazy val size = number[Int](classOf[Int], COL_SIZE, this)
@ -127,7 +135,7 @@ trait ListExpression[T, Q <: Expression[_ >: T]] extends CollectionExpressionBas
}
trait MapExpression[K, V, Q <: Expression[_ >: V]]
extends SimpleExpression[java.util.Map[K, V]] with com.mysema.query.types.MapExpression[K,V] {
extends DslExpression[java.util.Map[K, V]] with com.mysema.query.types.MapExpression[K,V] {
lazy val size = number[Int](classOf[Int], MAP_SIZE, this)

View File

@ -26,6 +26,10 @@ object Operations {
type Op[X] = Operator[X]
def dsl[T](t: Class[_ <: T], op: Op[_ >: T], args: Ex[_]*): DslExpression[T] = {
new OperationImpl[T](t, op, args: _*) with DslExpression[T]
}
def simple[T](t: Class[_ <: T], op: Op[_ >: T], args: Ex[_]*): SimpleExpression[T] = {
new OperationImpl[T](t, op, args: _*) with SimpleExpression[T]
}

View File

@ -35,6 +35,8 @@ object Paths {
def array[T <: Array[_]](t: Class[T], md: Metadata[_]) = new ArrayPath[T](t, md)
def dsl[T](t: Class[_ <: T], md: Metadata[_]) = new DslPath[T](t, md)
def simple[T](t: Class[_ <: T], md: Metadata[_]) = new SimplePath[T](t, md)
def entity[T](t: Class[_ <: T], md: Metadata[_]) = new EntityPathImpl[T](t, md)
@ -78,6 +80,13 @@ object Paths {
}
class DslPath[T](t: Class[_ <: T], md: PathMetadata[_])
extends PathImpl[T](t, md) with DslExpression[T] {
def this(t: Class[_ <: T], variable: String) = this(t, forVariable(variable))
}
class SimplePath[T](t: Class[_ <: T], md: PathMetadata[_])
extends PathImpl[T](t, md) with SimpleExpression[T] {

View File

@ -28,6 +28,10 @@ import com.mysema.codegen.model.TypeCategory
*/
object Templates {
def dsl[T](t: Class[_ <: T], tpl: Template, args: Ex[_]*): DslExpression[T] = {
new DslTemplate[T](t, tpl, args: _*)
}
def simple[T](t: Class[_ <: T], tpl: Template, args: Ex[_]*): SimpleExpression[T] = {
new SimpleTemplate[T](t, tpl, args: _*)
}
@ -62,6 +66,9 @@ object Templates {
}
class DslTemplate[T](t: Class[_ <: T], template: Template, args: Ex[_]*)
extends TemplateExpressionImpl[T](t, template, args:_*) with DslExpression[T]
class SimpleTemplate[T](t: Class[_ <: T], template: Template, args: Ex[_]*)
extends TemplateExpressionImpl[T](t, template, args:_*) with SimpleExpression[T]