This commit is contained in:
Timo Westkämper 2010-08-19 10:08:55 +00:00
parent e2a6cddd04
commit 6372eea38e
9 changed files with 15 additions and 124 deletions

View File

@ -9,7 +9,6 @@ import com.mysema.query.annotations.QueryDelegate;
import com.mysema.query.annotations.QueryEmbeddable;
import com.mysema.query.annotations.QueryEntity;
import com.mysema.query.annotations.QuerySupertype;
import com.mysema.query.types.Interval;
import com.mysema.query.types.expr.EBoolean;
import com.mysema.query.types.expr.EBooleanConst;
import com.mysema.query.types.path.PDate;
@ -17,6 +16,10 @@ import com.mysema.query.types.path.PDateTime;
public class QueryExtensions10Test {
public interface Interval<T>{
}
/**
* Adds a period filter
*/

View File

@ -642,7 +642,7 @@ public class EntitySerializer implements Serializer{
queryType = typeMappings.getPathType(property.getParameter(1), model, true);
serialize(model, property, new ClassType(PMap.class, getRaw(property.getParameter(0)), getRaw(property.getParameter(1)), genericQueryType),
writer, "this.<"+genericKey+COMMA+genericValue+COMMA+genericQueryType+">createMap",
writer, "this.<" + genericKey + COMMA + genericValue + COMMA + model.getRawName(genericQueryType) + ">createMap",
keyType+DOT_CLASS,
valueType+DOT_CLASS,
queryType+DOT_CLASS);
@ -652,7 +652,7 @@ public class EntitySerializer implements Serializer{
localRawName = model.getRawName(property.getParameter(0));
queryType = typeMappings.getPathType(property.getParameter(0), model, true);
serialize(model, property, new ClassType(PList.class, getRaw(property.getParameter(0)), genericQueryType), writer, "createList", localRawName + DOT_CLASS, queryType +DOT_CLASS);
serialize(model, property, new ClassType(PList.class, getRaw(property.getParameter(0)), genericQueryType), writer, "createList", localRawName + DOT_CLASS, model.getRawName(queryType) + DOT_CLASS);
break;
case ENTITY:
entityField(model, property, config, writer);
@ -662,7 +662,7 @@ public class EntitySerializer implements Serializer{
}
private Type getRaw(Type type) {
if (type instanceof EntityType){
if (type instanceof EntityType && type.getPackageName().startsWith("ext.java")){
return type;
}else{
return new SimpleType(type, type.getParameters());

View File

@ -10,6 +10,10 @@ import org.apache.commons.collections15.Transformer;
import com.mysema.query.types.expr.EString;
import com.mysema.query.types.expr.EStringEscape;
/**
* @author tiwe
*
*/
public final class Converters {
private Converters(){}

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2010 Mysema Ltd.
* All rights reserved.
*
*/
package com.mysema.query.types;
import javax.annotation.Nullable;
/**
* Interval is a typed inclusive interval from begin to end with optional open begin and end
*
* @author tiwe
*
* @param <T>
*/
public interface Interval<T> {
/**
* Get the beginning of the interval or null
*
* @return
*/
@Nullable
T getBegin();
/**
* Get the end of the interval or null
*
* @return
*/
@Nullable
T getEnd();
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2010 Mysema Ltd.
* All rights reserved.
*
*/
package com.mysema.query.types;
import javax.annotation.Nullable;
/**
* Default implementation of the interval interface
*
* @author tiwe
*
* @param <T>
*/
public class IntervalImpl<T> implements Interval<T> {
public static <T> Interval<T> create(@Nullable T begin, @Nullable T end){
return new IntervalImpl<T>(begin, end);
}
@Nullable
private final T begin, end;
public IntervalImpl(@Nullable T begin, @Nullable T end){
this.begin = begin;
this.end = end;
}
@Override
public T getBegin() {
return begin;
}
@Override
public T getEnd() {
return end;
}
}

View File

@ -16,7 +16,6 @@ import com.mysema.query.BooleanBuilder;
import com.mysema.query.JoinFlag;
import com.mysema.query.QueryFlag;
import com.mysema.query.QueryFlag.Position;
import com.mysema.query.types.*;
/**
* SerializerBase is a stub for Serializer implementations

View File

@ -5,9 +5,7 @@
*/
package com.mysema.query.types.expr;
import com.mysema.query.BooleanBuilder;
import com.mysema.query.types.Expr;
import com.mysema.query.types.Interval;
import com.mysema.query.types.Operator;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
@ -165,21 +163,4 @@ public abstract class EComparable<D extends Comparable> extends EComparableBase<
return OBoolean.create(Ops.BOE, this, right);
}
/**
* Get <code>this in period</code> expression
*
* @param period
* @return
*/
public EBoolean in(Interval<D> period) {
BooleanBuilder builder = new BooleanBuilder();
if (period.getBegin() != null) {
builder.and(goe(period.getBegin()));
}
if (period.getEnd() != null) {
builder.and(loe(period.getEnd()));
}
return builder.getValue();
}
}

View File

@ -12,9 +12,7 @@ import java.util.List;
import javax.annotation.Nullable;
import com.mysema.query.BooleanBuilder;
import com.mysema.query.types.Expr;
import com.mysema.query.types.Interval;
import com.mysema.query.types.Operator;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
@ -344,23 +342,6 @@ public abstract class ENumber<D extends Number & Comparable<?>> extends ECompara
return castToNum(Integer.class);
}
/**
* Get <code>this in period</code> expression
*
* @param period
* @return
*/
public <A extends Number & Comparable<?>> EBoolean in(Interval<A> period) {
BooleanBuilder builder = new BooleanBuilder();
if (period.getBegin() != null) {
builder.and(goe(period.getBegin()));
}
if (period.getEnd() != null) {
builder.and(loe(period.getEnd()));
}
return builder.getValue();
}
/**
* Create a <code>this &lt;= right</code> expression
*

View File

@ -12,7 +12,6 @@ import java.util.HashSet;
import java.util.List;
import com.mysema.query.types.Expr;
import com.mysema.query.types.IntervalImpl;
import com.mysema.query.types.Path;
import com.mysema.query.types.expr.*;
@ -76,8 +75,8 @@ public class Filters {
rv.add(expr.loe(other));
rv.add(expr.loe(knownValue));
rv.add(expr.in(IntervalImpl.create(knownValue, null)));
rv.add(expr.in(IntervalImpl.create(null, knownValue)));
// rv.add(expr.in(IntervalImpl.create(knownValue, null)));
// rv.add(expr.in(IntervalImpl.create(null, knownValue)));
return rv;
@ -195,7 +194,7 @@ public class Filters {
rv.add(elong.mod(5l).eq(0l));
}
rv.add(expr.in(IntervalImpl.create(0, 100)));
// rv.add(expr.in(IntervalImpl.create(0, 100)));
return rv;
}
@ -279,7 +278,7 @@ public class Filters {
rv.add(new Coalesce<String>(String.class, expr, other).eq("xxx"));
}
rv.add(expr.in(IntervalImpl.create("A", "Z")));
// rv.add(expr.in(IntervalImpl.create("A", "Z")));
return rv;
}