mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
removed EDecimal and related classes
This commit is contained in:
parent
eba20af923
commit
7c13a8a53b
@ -6,13 +6,9 @@
|
||||
package com.mysema.query.collections.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.query.alias.Alias;
|
||||
import com.mysema.query.collections.ColQuery;
|
||||
import com.mysema.query.types.OrderSpecifier;
|
||||
import com.mysema.query.types.SinglePathExtractor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
|
||||
/**
|
||||
@ -35,15 +31,4 @@ public class MiniApi {
|
||||
return new ColQueryImpl().from(Alias.$(alias), col);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <A> List<A> select(Iterable<A> from, EBoolean where, OrderSpecifier<?>... order) {
|
||||
Expr<A> path = (Expr<A>) new SinglePathExtractor().handle(where).getPath();
|
||||
ColQuery query = new ColQueryImpl().from(path, from).where(where).orderBy(order);
|
||||
return query.list((Expr<A>) path);
|
||||
}
|
||||
|
||||
public static <A> List<A> reject(Iterable<A> from, EBoolean where, OrderSpecifier<?>... order) {
|
||||
return select(from, where.not(), order);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.collections.impl;
|
||||
|
||||
import static com.mysema.query.alias.Alias.$;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.collections.domain.Cat;
|
||||
|
||||
|
||||
/**
|
||||
* MiniApiTest provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MiniApiTest extends AbstractQueryTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleReject() {
|
||||
// Iterable<Integer> oneAndTwo = reject(myInts, greaterThan(2));
|
||||
Iterable<Integer> oneAndTwo = MiniApi.reject(myInts, $(0).gt(2));
|
||||
|
||||
for (Integer i : oneAndTwo)
|
||||
ints.add(i);
|
||||
assertEquals(Arrays.asList(1, 2), ints);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleSelect() {
|
||||
// Iterable<Integer> threeAndFour = select(myInts, greaterThan(2));
|
||||
Iterable<Integer> threeAndFour = MiniApi.select(myInts, $(0).gt(2));
|
||||
|
||||
for (Integer i : threeAndFour){
|
||||
ints.add(i);
|
||||
}
|
||||
assertEquals(Arrays.asList(3, 4), ints);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMiniApiUsage() {
|
||||
for (Cat c : MiniApi.select(cats, cat.name.eq("Kitty"))) {
|
||||
System.out.println(c.getName());
|
||||
}
|
||||
MiniApi.select(cats, cat.kittens.size().gt(0)).iterator();
|
||||
MiniApi.select(cats, cat.mate.isNotNull()).iterator();
|
||||
MiniApi.select(cats, cat.alive.and(cat.birthdate.isNotNull())).iterator();
|
||||
MiniApi.select(cats, cat.bodyWeight.lt(cat.weight)).iterator();
|
||||
MiniApi.select(cats, cat.color.isNull().or(cat.eyecolor.eq(cat.color))).iterator();
|
||||
MiniApi.select(cats, cat.bodyWeight.between(1, 2)).iterator();
|
||||
|
||||
// from where order
|
||||
MiniApi.select(cats, cat.name.eq("Kitty"), cat.name.asc()).iterator();
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package com.mysema.query.functions;
|
||||
|
||||
import com.mysema.query.types.expr.EDecimal;
|
||||
import com.mysema.query.types.expr.ENumber;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.ONumber;
|
||||
@ -67,7 +66,7 @@ public final class MathFunctions {
|
||||
* use left.ceil() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static ENumber<Double> ceil(EDecimal<Double> left) {
|
||||
public static ENumber<Double> ceil(ENumber<Double> left) {
|
||||
return left.ceil();
|
||||
}
|
||||
|
||||
@ -75,7 +74,7 @@ public final class MathFunctions {
|
||||
* use left.round() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static ENumber<Double> round(EDecimal<Double> left) {
|
||||
public static ENumber<Double> round(ENumber<Double> left) {
|
||||
return left.round();
|
||||
}
|
||||
|
||||
@ -83,7 +82,7 @@ public final class MathFunctions {
|
||||
* use left.floor() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static ENumber<Double> floor(EDecimal<Double> left) {
|
||||
public static ENumber<Double> floor(ENumber<Double> left) {
|
||||
return left.floor();
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.OComparable;
|
||||
import com.mysema.query.types.operation.ODate;
|
||||
import com.mysema.query.types.operation.ODateTime;
|
||||
import com.mysema.query.types.operation.ODecimal;
|
||||
import com.mysema.query.types.operation.ONumber;
|
||||
import com.mysema.query.types.operation.OSimple;
|
||||
import com.mysema.query.types.operation.OString;
|
||||
@ -32,7 +31,6 @@ import com.mysema.query.types.path.PComponentList;
|
||||
import com.mysema.query.types.path.PComponentMap;
|
||||
import com.mysema.query.types.path.PDate;
|
||||
import com.mysema.query.types.path.PDateTime;
|
||||
import com.mysema.query.types.path.PDecimal;
|
||||
import com.mysema.query.types.path.PEntity;
|
||||
import com.mysema.query.types.path.PEntityCollection;
|
||||
import com.mysema.query.types.path.PEntityList;
|
||||
@ -106,11 +104,6 @@ public abstract class AbstractVisitor<SubType extends AbstractVisitor<SubType>>
|
||||
visit((Operation<?, ?>) expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(ODecimal<?, ?> expr) {
|
||||
visit((Operation<?, ?>) expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(OSimple<?, ?> expr) {
|
||||
visit((Operation<?, ?>) expr);
|
||||
@ -205,12 +198,7 @@ public abstract class AbstractVisitor<SubType extends AbstractVisitor<SubType>>
|
||||
protected void visit(PNumber<?> expr) {
|
||||
visit((Path<?>) expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(PDecimal<?> expr) {
|
||||
visit((Path<?>) expr);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void visit(PDate<?> expr) {
|
||||
visit((Path<?>) expr);
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types;
|
||||
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.Operation;
|
||||
|
||||
/**
|
||||
* DeepVisitor provides deep dispatching functionality
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class DeepVisitor<SubType extends DeepVisitor<SubType>> extends EmptyVisitor<SubType> {
|
||||
|
||||
@Override
|
||||
protected void visit(Operation<?, ?> o) {
|
||||
for (Expr<?> expr : o.getArgs()){
|
||||
handle(expr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types;
|
||||
|
||||
import com.mysema.query.types.custom.Custom;
|
||||
import com.mysema.query.types.expr.EConstant;
|
||||
import com.mysema.query.types.operation.Operation;
|
||||
import com.mysema.query.types.path.Path;
|
||||
|
||||
/**
|
||||
* EmptyVisitor is an empty implementation of the Visitor class
|
||||
*
|
||||
* @author tiwe
|
||||
*
|
||||
*/
|
||||
public class EmptyVisitor<SubType extends EmptyVisitor<SubType>> extends AbstractVisitor<SubType>{
|
||||
|
||||
|
||||
@Override
|
||||
protected void visit(Custom<?> expr) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(EConstant<?> expr) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(Operation<?, ?> expr) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(Path<?> expr) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types;
|
||||
|
||||
import com.mysema.query.types.path.Path;
|
||||
|
||||
/**
|
||||
* SinglePathExtractor is a visitor implementation which returns the top level path
|
||||
* from a single Expr instance
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SinglePathExtractor extends DeepVisitor<SinglePathExtractor> {
|
||||
|
||||
private Path<?> path;
|
||||
|
||||
@Override
|
||||
protected void visit(Path<?> expr) {
|
||||
path = expr.getRoot();
|
||||
}
|
||||
|
||||
public Path<?> getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
@ -26,7 +26,6 @@ import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.OComparable;
|
||||
import com.mysema.query.types.operation.ODate;
|
||||
import com.mysema.query.types.operation.ODateTime;
|
||||
import com.mysema.query.types.operation.ODecimal;
|
||||
import com.mysema.query.types.operation.ONumber;
|
||||
import com.mysema.query.types.operation.OSimple;
|
||||
import com.mysema.query.types.operation.OString;
|
||||
@ -44,7 +43,6 @@ import com.mysema.query.types.path.PComponentList;
|
||||
import com.mysema.query.types.path.PComponentMap;
|
||||
import com.mysema.query.types.path.PDate;
|
||||
import com.mysema.query.types.path.PDateTime;
|
||||
import com.mysema.query.types.path.PDecimal;
|
||||
import com.mysema.query.types.path.PEntity;
|
||||
import com.mysema.query.types.path.PEntityCollection;
|
||||
import com.mysema.query.types.path.PEntityList;
|
||||
@ -118,7 +116,7 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
}
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
protected abstract void visit(CBoolean expr);
|
||||
|
||||
protected abstract void visit(CComparable<?> expr);
|
||||
@ -143,8 +141,6 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
protected abstract void visit(ONumber<?, ?> expr);
|
||||
|
||||
protected abstract void visit(ODecimal<?, ?> expr);
|
||||
|
||||
protected abstract void visit(Operation<?, ?> expr);
|
||||
|
||||
protected abstract void visit(OSimple<?, ?> expr);
|
||||
@ -187,8 +183,6 @@ public abstract class Visitor<T extends Visitor<T>> {
|
||||
|
||||
protected abstract void visit(PNumber<?> expr);
|
||||
|
||||
protected abstract void visit(PDecimal<?> expr);
|
||||
|
||||
protected abstract void visit(PSimple<?> expr);
|
||||
|
||||
protected abstract void visit(PString expr);
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types.expr;
|
||||
|
||||
import com.mysema.query.types.operation.ONumber;
|
||||
import com.mysema.query.types.operation.Ops.MathOps;
|
||||
|
||||
/**
|
||||
* EDecimal represents decimal expressions
|
||||
*
|
||||
* @author tiwe
|
||||
*
|
||||
* @param <D>
|
||||
*/
|
||||
public abstract class EDecimal<D extends Number & Comparable<?>> extends ENumber<D> {
|
||||
|
||||
public EDecimal(Class<? extends D> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
private ENumber<D> round, floor, ceil;
|
||||
|
||||
/**
|
||||
* @return round(this)
|
||||
* @see java.lang.Math#round(double)
|
||||
* @see java.lang.Math#round(float)
|
||||
*/
|
||||
public ENumber<D> round() {
|
||||
if (round == null){
|
||||
round = ONumber.create(getType(), MathOps.ROUND, this);
|
||||
}
|
||||
return round;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return floor(this)
|
||||
* @see java.lang.Math#floor(double)
|
||||
*/
|
||||
public ENumber<D> floor() {
|
||||
if (floor == null){
|
||||
floor = ONumber.create(getType(), MathOps.FLOOR, this);
|
||||
}
|
||||
return floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ceil(this)
|
||||
* @see java.lang.Math#ceil(double)
|
||||
*/
|
||||
public ENumber<D> ceil() {
|
||||
if (ceil == null){
|
||||
ceil = ONumber.create(getType(), MathOps.CEIL, this);
|
||||
}
|
||||
return ceil;
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,7 +9,6 @@ import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.ODecimal;
|
||||
import com.mysema.query.types.operation.ONumber;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.types.operation.Ops.MathOps;
|
||||
@ -25,7 +24,7 @@ import com.mysema.query.types.operation.Ops.MathOps;
|
||||
*/
|
||||
public abstract class ENumber<D extends Number & Comparable<?>> extends EComparable<D> {
|
||||
|
||||
private static EDecimal<Double> random;
|
||||
private static ENumber<Double> random;
|
||||
|
||||
/**
|
||||
* @return max(left, right)
|
||||
@ -45,16 +44,18 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
* Returns the random expression
|
||||
* @return random()
|
||||
*/
|
||||
public static EDecimal<Double> random(){
|
||||
public static ENumber<Double> random(){
|
||||
if (random == null){
|
||||
random = ODecimal.create(Double.class, MathOps.RANDOM);
|
||||
random = ONumber.create(Double.class, MathOps.RANDOM);
|
||||
}
|
||||
return random;
|
||||
}
|
||||
|
||||
private ENumber<D> abs, sum, min, max;
|
||||
|
||||
private EDecimal<Double> avg, sqrt;
|
||||
private ENumber<Double> avg, sqrt;
|
||||
|
||||
private ENumber<D> round, floor, ceil;
|
||||
|
||||
public ENumber(Class<? extends D> type) {
|
||||
super(type);
|
||||
@ -69,7 +70,7 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
}
|
||||
return abs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this + right
|
||||
@ -77,7 +78,7 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
public ENumber<D> add(D right) {
|
||||
return ONumber.create(getType(), Ops.ADD, this, EConstant.create(right));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this + right
|
||||
@ -85,13 +86,13 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
public ENumber<D> add(Expr<D> right) {
|
||||
return ONumber.create(getType(), Ops.ADD, this, right);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return avg(this)
|
||||
*/
|
||||
public EDecimal<Double> avg(){
|
||||
public ENumber<Double> avg(){
|
||||
if (avg == null){
|
||||
avg = ODecimal.create(Double.class, Ops.AggOps.AVG_AGG, this);
|
||||
avg = ONumber.create(Double.class, Ops.AggOps.AVG_AGG, this);
|
||||
}
|
||||
return avg;
|
||||
}
|
||||
@ -143,20 +144,30 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
}
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this / right
|
||||
* @return ceil(this)
|
||||
* @see java.lang.Math#ceil(double)
|
||||
*/
|
||||
public EDecimal<Double> div(D right) {
|
||||
return ODecimal.create(Double.class, Ops.DIV, this, EConstant.create(right));
|
||||
public ENumber<D> ceil() {
|
||||
if (ceil == null){
|
||||
ceil = ONumber.create(getType(), MathOps.CEIL, this);
|
||||
}
|
||||
return ceil;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this / right
|
||||
*/
|
||||
public EDecimal<Double> div(Expr<D> right) {
|
||||
return ODecimal.create(Double.class, Ops.DIV, this, right);
|
||||
public ENumber<Double> div(D right) {
|
||||
return ONumber.create(Double.class, Ops.DIV, this, EConstant.create(right));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this / right
|
||||
*/
|
||||
public ENumber<Double> div(Expr<D> right) {
|
||||
return ONumber.create(Double.class, Ops.DIV, this, right);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,6 +180,7 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
return castToNum(Double.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the float expression of this numeric expression
|
||||
*
|
||||
@ -179,6 +191,17 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
return castToNum(Float.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return floor(this)
|
||||
* @see java.lang.Math#floor(double)
|
||||
*/
|
||||
public ENumber<D> floor() {
|
||||
if (floor == null){
|
||||
floor = ONumber.create(getType(), MathOps.FLOOR, this);
|
||||
}
|
||||
return floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>this >= right</code> expression
|
||||
*
|
||||
@ -314,7 +337,7 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this * right
|
||||
@ -322,7 +345,7 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
public ENumber<D> mult(D right) {
|
||||
return ONumber.create(getType(), Ops.MULT, this, EConstant.create(right));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param right
|
||||
* @return this * right
|
||||
@ -330,6 +353,18 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
public ENumber<D> mult(Expr<D> right) {
|
||||
return ONumber.create(getType(), Ops.MULT, this, right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return round(this)
|
||||
* @see java.lang.Math#round(double)
|
||||
* @see java.lang.Math#round(float)
|
||||
*/
|
||||
public ENumber<D> round() {
|
||||
if (round == null){
|
||||
round = ONumber.create(getType(), MathOps.ROUND, this);
|
||||
}
|
||||
return round;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short expression of this numeric expression
|
||||
@ -345,9 +380,9 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
|
||||
* Returns the square root of this numeric expressions
|
||||
* @return sqrt(this)
|
||||
*/
|
||||
public EDecimal<Double> sqrt(){
|
||||
public ENumber<Double> sqrt(){
|
||||
if (sqrt == null){
|
||||
sqrt = ODecimal.create(Double.class, MathOps.SQRT, this);
|
||||
sqrt = ONumber.create(Double.class, MathOps.SQRT, this);
|
||||
}
|
||||
return sqrt;
|
||||
}
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types.operation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.query.types.expr.EDecimal;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
|
||||
/**
|
||||
* ONumber represents numeric operations
|
||||
*
|
||||
* @author tiwe
|
||||
*
|
||||
* @param <OpType>
|
||||
* @param <D>
|
||||
*/
|
||||
public class ODecimal<OpType extends Number, D extends Number & Comparable<?>>
|
||||
extends EDecimal<D> implements Operation<OpType, D> {
|
||||
|
||||
private final List<Expr<?>> args;
|
||||
|
||||
private final Operator<OpType> op;
|
||||
|
||||
ODecimal(Class<? extends D> type, Operator<OpType> op, Expr<?>... args) {
|
||||
this(type, op, Arrays.asList(args));
|
||||
}
|
||||
|
||||
ODecimal(Class<? extends D> type, Operator<OpType> op, List<Expr<?>> args) {
|
||||
super(type);
|
||||
this.op = op;
|
||||
this.args = Collections.unmodifiableList(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Expr<?>> getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expr<?> getArg(int i) {
|
||||
return args.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operator<OpType> getOperator() {
|
||||
return op;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method
|
||||
*
|
||||
* @param <O>
|
||||
* @param <D>
|
||||
* @param type
|
||||
* @param op
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
public static <O extends Number,D extends Number & Comparable<?>> EDecimal<D> create(Class<? extends D> type, Operator<O> op, Expr<?>... args){
|
||||
return new ODecimal<O,D>(type, op, args);
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types.path;
|
||||
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.EDecimal;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
* PNumber represents numeric paths
|
||||
*
|
||||
* @author tiwe
|
||||
*
|
||||
* @param <D> Java type
|
||||
*/
|
||||
public class PDecimal<D extends Number & Comparable<?>> extends EDecimal<D> implements Path<D> {
|
||||
|
||||
private EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
public PDecimal(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
public PDecimal(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata)
|
||||
: false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = new OBoolean(Ops.ISNOTNULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = new OBoolean(Ops.ISNULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
}
|
||||
@ -100,17 +100,6 @@ public class PEntity<D> extends EEntity<D> implements Path<D> {
|
||||
Class<A> type) {
|
||||
return new PDateTime<A>(type, PathMetadata.forProperty(this, propertyName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A extends Number & Comparable<?>> PDecimal<A> _decimal(
|
||||
@NotEmpty String property, Class<A> type) {
|
||||
return new PDecimal<A>(type, PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Entity subpath for the given property
|
||||
|
||||
@ -28,9 +28,6 @@
|
||||
<#list decl.numericFields as field>
|
||||
<@numericField field=field/>
|
||||
</#list>
|
||||
<#list decl.decimalFields as field>
|
||||
<@decimalField field=field/>
|
||||
</#list>
|
||||
<#list decl.simpleMaps as field>
|
||||
<@simpleMap field=field/>
|
||||
</#list>
|
||||
@ -139,11 +136,6 @@
|
||||
/** ${field.docString} */
|
||||
public final PNumber<${field.typeName}> ${field.name} = _number("${field.name}",${field.typeName}.class);
|
||||
</#macro>
|
||||
|
||||
<#macro decimalField field>
|
||||
/** ${field.docString} */
|
||||
public final PDecimal<${field.typeName}> ${field.name} = _decimal("${field.name}",${field.typeName}.class);
|
||||
</#macro>
|
||||
|
||||
<#macro simpleField field>
|
||||
/** ${field.docString} */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user