mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
refactored Path implementations to use PathMixin as a delegate
This commit is contained in:
parent
4b108ffdab
commit
b9f8bac585
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types.expr;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
|
||||
@ -14,7 +14,6 @@ import com.mysema.query.types.expr.EArray;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.ENumber;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.ONumber;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
|
||||
@ -32,31 +31,31 @@ public class PArray<E> extends Expr<E[]> implements Path<E[]>, EArray<E>{
|
||||
|
||||
private final Class<E> componentType;
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
private final Path<E[]> pathMixin;
|
||||
|
||||
private volatile ENumber<Integer> size;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PArray(Class<? super E> type, PathMetadata<?> metadata) {
|
||||
super((Class)Object[].class);
|
||||
this.pathMixin = new PathMixin<E[]>(this, metadata);
|
||||
this.arrayType = (Class<E[]>) Array.newInstance(type, 0).getClass();
|
||||
this.componentType = (Class<E>) type;
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
// public PArray(Class<E> type, @NotEmpty String var) {
|
||||
// this(type, PathMetadata.forVariable(var));
|
||||
// }
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Expr<E[]> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata)
|
||||
: false;
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,6 +69,7 @@ public class PArray<E> extends Expr<E[]> implements Path<E[]>, EArray<E>{
|
||||
return new PSimple<E>(componentType, md);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a expression for indexed access
|
||||
*
|
||||
@ -81,21 +81,21 @@ public class PArray<E> extends Expr<E[]> implements Path<E[]>, EArray<E>{
|
||||
return new PSimple<E>(componentType, md);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Override
|
||||
public Class<E> getElementType() {
|
||||
return componentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<E[]> getType() {
|
||||
return arrayType;
|
||||
@ -103,25 +103,19 @@ public class PArray<E> extends Expr<E[]> implements Path<E[]>, EArray<E>{
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an expression for the array size
|
||||
*
|
||||
@ -133,14 +127,5 @@ public class PArray<E> extends Expr<E[]> implements Path<E[]>, EArray<E>{
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expr<E[]> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,8 +7,6 @@ package com.mysema.query.types.path;
|
||||
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -20,71 +18,59 @@ import com.mysema.query.util.NotEmpty;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class PBoolean extends EBoolean implements Path<Boolean> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
public PBoolean(PathMetadata<?> metadata) {
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
private final Path<Boolean> pathMixin;
|
||||
|
||||
public PBoolean(@NotEmpty String var) {
|
||||
this(PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
public PBoolean(Path<?> parent, @NotEmpty String property) {
|
||||
this(PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata)
|
||||
: false;
|
||||
public PBoolean(PathMetadata<?> metadata) {
|
||||
this.pathMixin = new PathMixin<Boolean>(this, metadata);
|
||||
}
|
||||
|
||||
@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 = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
|
||||
public PBoolean(@NotEmpty String var) {
|
||||
this(PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@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 EBoolean isNotNull() {
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,8 +12,6 @@ import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.ECollectionBase;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -26,23 +24,18 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings("serial")
|
||||
public class PCollection<E> extends ECollectionBase<Collection<E>,E> implements Path<Collection<E>> {
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Class<E> elementType;
|
||||
|
||||
private final String entityName;
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final Path<?> root;
|
||||
private final Path<Collection<E>> pathMixin;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PCollection(Class<? super E> type, @NotEmpty String entityName, PathMetadata<?> metadata) {
|
||||
super((Class)Collection.class);
|
||||
super((Class)Collection.class);
|
||||
this.elementType = (Class<E>) Assert.notNull(type,"type is null");
|
||||
this.metadata = Assert.notNull(metadata,"metadata is null");
|
||||
this.entityName = Assert.notNull(entityName,"entityName is null");
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
this.pathMixin = new PathMixin<Collection<E>>(this, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,17 +43,21 @@ public class PCollection<E> extends ECollectionBase<Collection<E>,E> implements
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata) : false;
|
||||
public Expr<Collection<E>> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<E> getElementType() {
|
||||
return elementType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the entity name for this Entity collection path
|
||||
*
|
||||
@ -69,42 +66,30 @@ public class PCollection<E> extends ECollectionBase<Collection<E>,E> implements
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Expr<Collection<E>> asExpr() {
|
||||
return this;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.EComparable;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -21,75 +19,64 @@ import com.mysema.query.util.NotEmpty;
|
||||
* @see java.util.Comparable
|
||||
*/
|
||||
@SuppressWarnings({"unchecked","serial"})
|
||||
public class PComparable<D extends Comparable> extends EComparable<D> implements
|
||||
Path<D> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
public class PComparable<D extends Comparable> extends EComparable<D> implements Path<D> {
|
||||
|
||||
public PComparable(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
public PComparable(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
public PComparable(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public PComparable(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
}
|
||||
|
||||
public PComparable(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
public PComparable(Path<?> parent, @NotEmpty String property) {
|
||||
this((Class<? extends D>) Comparable.class, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EComparable<D> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EComparable<D> asExpr() {
|
||||
return this;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.EDate;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -20,70 +18,59 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings({"unchecked","serial"})
|
||||
public class PDate<D extends Comparable> extends EDate<D> implements Path<D>{
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
public PDate(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public PDate(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
}
|
||||
|
||||
public PDate(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
public PDate(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata)
|
||||
: false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EDate<D> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EDate<D> asExpr() {
|
||||
return this;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.EDateTime;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -20,69 +18,58 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings({"unchecked","serial"})
|
||||
public class PDateTime<D extends Comparable> extends EDateTime<D> implements Path<D> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
public PDateTime(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public PDateTime(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
}
|
||||
|
||||
public PDateTime(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
public PDateTime(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata)
|
||||
: false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@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 = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EDateTime<D> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@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 EBoolean isNotNull() {
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,17 +30,12 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
|
||||
private final String entityName;
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
public PEntity(Class<? extends D> type, @NotEmpty String entityName, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
this.entityName = entityName;
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,6 +71,16 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A> PArray<A> createArray(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PArray<A>(type, PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param propertyName
|
||||
* @return
|
||||
@ -84,6 +89,16 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
return new PBoolean(this, propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A> PCollection<A> createCollection(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PCollection<A>(type, type.getSimpleName(), PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
@ -94,7 +109,7 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
protected <A extends Comparable> PComparable<A> createComparable(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PComparable<A>((Class)type, this, property);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
@ -117,36 +132,6 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
return new PDateTime<A>((Class)type, this, property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A> PArray<A> createArray(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PArray<A>(type, PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A> PCollection<A> createCollection(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PCollection<A>(type, type.getSimpleName(), PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A> PSet<A> createSet(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PSet<A>(type, type.getSimpleName(), PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param <E>
|
||||
@ -186,6 +171,16 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
return new PNumber<A>((Class)type, this, property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param property
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected <A> PSet<A> createSet(@NotEmpty String property, Class<? super A> type) {
|
||||
return new PSet<A>(type, type.getSimpleName(), PathMetadata.forProperty(this, property));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <A>
|
||||
* @param path
|
||||
@ -216,11 +211,12 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
return new PTime<A>((Class)type, this, property);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata) : false;
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the entity name for this Entity path
|
||||
@ -233,17 +229,17 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,20 +252,14 @@ public class PEntity<D> extends Expr<D> implements Path<D> {
|
||||
public <B extends D> EBoolean instanceOf(Class<B> type) {
|
||||
return OBoolean.create(Ops.INSTANCE_OF, this, ExprConst.create(type));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
@ -19,8 +19,6 @@ import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.ECollectionBase;
|
||||
import com.mysema.query.types.expr.EList;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -48,24 +46,19 @@ public class PList<E, Q extends Expr<E>> extends ECollectionBase<List<E>,E> impl
|
||||
|
||||
protected final String entityName;
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
private final Path<List<E>> pathMixin;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Class<Q> queryType;
|
||||
private final Class<Q> queryType;
|
||||
|
||||
private Constructor<Q> queryTypeConstructor;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PList(Class<? super E> elementType, @NotEmpty String entityName, Class<Q> queryType, PathMetadata<?> metadata) {
|
||||
super((Class)List.class);
|
||||
this.elementType = (Class<E>) Assert.notNull(elementType,"type is null");
|
||||
this.metadata = Assert.notNull(metadata,"metadata is null");
|
||||
this.entityName = Assert.notNull(entityName,"entityName is null");
|
||||
this.queryType = queryType;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
this.pathMixin = new PathMixin<List<E>>(this, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,6 +80,11 @@ public class PList<E, Q extends Expr<E>> extends ECollectionBase<List<E>,E> impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Q get(Expr<Integer> index) {
|
||||
PathMetadata<Integer> md = PathMetadata.forListAccess(this, index);
|
||||
@ -112,31 +110,30 @@ public class PList<E, Q extends Expr<E>> extends ECollectionBase<List<E>,E> impl
|
||||
public Class<E> getElementType() {
|
||||
return elementType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
public int hashCode() {
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
private Q newInstance(PathMetadata<?> pm) throws Exception{
|
||||
|
||||
@ -15,8 +15,6 @@ import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.EMapBase;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
|
||||
/**
|
||||
* PMap represents map paths
|
||||
@ -37,30 +35,24 @@ public class PMap<K, V, E extends Expr<V>> extends EMapBase<K, V> implements Pat
|
||||
PSimple.class,
|
||||
PTime.class
|
||||
));
|
||||
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
|
||||
private final Class<K> keyType;
|
||||
|
||||
private final Class<V> valueType;
|
||||
private final Path<Map<K,V>> pathMixin;
|
||||
|
||||
private final Class<E> queryType;
|
||||
|
||||
private Constructor<E> queryTypeConstructor;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
private final Class<V> valueType;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PMap(Class<? super K> keyType, Class<? super V> valueType, Class<E> queryType, PathMetadata<?> metadata) {
|
||||
super((Class)Map.class);
|
||||
this.keyType = (Class<K>) keyType;
|
||||
this.valueType = (Class<V>) valueType;
|
||||
this.queryType = queryType;
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
this.pathMixin = new PathMixin<Map<K,V>>(this, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,29 +60,14 @@ public class PMap<K, V, E extends Expr<V>> extends EMapBase<K, V> implements Pat
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PMap<K,V,E> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata) : false;
|
||||
}
|
||||
|
||||
private E newInstance(PathMetadata<?> pm) throws Exception{
|
||||
if (queryTypeConstructor == null){
|
||||
try {
|
||||
if (typedClasses.contains(queryType)){
|
||||
queryTypeConstructor = queryType.getConstructor(Class.class, PathMetadata.class);
|
||||
}else{
|
||||
queryTypeConstructor = queryType.getConstructor(PathMetadata.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (typedClasses.contains(queryType)){
|
||||
return queryTypeConstructor.newInstance(getValueType(), pm);
|
||||
}else{
|
||||
return queryTypeConstructor.newInstance(pm);
|
||||
}
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,51 +89,59 @@ public class PMap<K, V, E extends Expr<V>> extends EMapBase<K, V> implements Pat
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<K> getKeyType() {
|
||||
return keyType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<V> getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PMap<K,V,E> asExpr() {
|
||||
return this;
|
||||
private E newInstance(PathMetadata<?> pm) throws Exception{
|
||||
if (queryTypeConstructor == null){
|
||||
try {
|
||||
if (typedClasses.contains(queryType)){
|
||||
queryTypeConstructor = queryType.getConstructor(Class.class, PathMetadata.class);
|
||||
}else{
|
||||
queryTypeConstructor = queryType.getConstructor(PathMetadata.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (typedClasses.contains(queryType)){
|
||||
return queryTypeConstructor.newInstance(getValueType(), pm);
|
||||
}else{
|
||||
return queryTypeConstructor.newInstance(pm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.ENumber;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -22,71 +20,58 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings("serial")
|
||||
public class PNumber<D extends Number & Comparable<?>> extends ENumber<D> implements Path<D> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
public PNumber(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public PNumber(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
public PNumber(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
}
|
||||
|
||||
public PNumber(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
public PNumber(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@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 = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ENumber<D> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@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 EBoolean isNotNull() {
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.types.path;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mysema.commons.lang.Assert;
|
||||
@ -8,8 +12,6 @@ import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.ECollectionBase;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -22,23 +24,18 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings("serial")
|
||||
public class PSet<E> extends ECollectionBase<Set<E>,E> implements Path<Set<E>> {
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Class<E> elementType;
|
||||
|
||||
private final String entityName;
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final Path<?> root;
|
||||
private final Path<Set<E>> pathMixin;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PSet(Class<? super E> type, @NotEmpty String entityName, PathMetadata<?> metadata) {
|
||||
super((Class)Set.class);
|
||||
this.elementType = (Class<E>) Assert.notNull(type,"type is null");
|
||||
this.metadata = Assert.notNull(metadata,"metadata is null");
|
||||
this.elementType = (Class<E>) Assert.notNull(type,"type is null");
|
||||
this.entityName = Assert.notNull(entityName,"entityName is null");
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
this.pathMixin = new PathMixin<Set<E>>(this, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,17 +43,21 @@ public class PSet<E> extends ECollectionBase<Set<E>,E> implements Path<Set<E>> {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata) : false;
|
||||
public Expr<Set<E>> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<E> getElementType() {
|
||||
return elementType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the entity name for this Entity collection path
|
||||
*
|
||||
@ -65,42 +66,30 @@ public class PSet<E> extends ECollectionBase<Set<E>,E> implements Path<Set<E>> {
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Expr<Set<E>> asExpr() {
|
||||
return this;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -22,72 +20,58 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings("serial")
|
||||
public class PSimple<D> extends Expr<D> implements Path<D> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
public PSimple(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
public PSimple(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
public PSimple(Class<? extends D> type, @NotEmpty Path<?> parent, String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public PSimple(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
}
|
||||
|
||||
public PSimple(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@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 = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expr<D> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@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 EBoolean isNotNull() {
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.EString;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -20,68 +18,58 @@ import com.mysema.query.util.NotEmpty;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class PString extends EString implements Path<String> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
public PString(PathMetadata<?> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public PString(@NotEmpty String var) {
|
||||
this(PathMetadata.forVariable(var));
|
||||
}
|
||||
private final Path<String> pathMixin;
|
||||
|
||||
public PString(Path<?> parent, @NotEmpty String property) {
|
||||
this(PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public PString(PathMetadata<?> metadata) {
|
||||
this.pathMixin = new PathMixin<String>(this, metadata);
|
||||
}
|
||||
|
||||
public PString(@NotEmpty String var) {
|
||||
this(PathMetadata.forVariable(var));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@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 metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EString asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@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 EBoolean isNotNull() {
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,6 @@ package com.mysema.query.types.path;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
import com.mysema.query.types.expr.ETime;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
import com.mysema.query.util.NotEmpty;
|
||||
|
||||
/**
|
||||
@ -20,69 +18,57 @@ import com.mysema.query.util.NotEmpty;
|
||||
@SuppressWarnings({"unchecked","serial"})
|
||||
public class PTime<D extends Comparable> extends ETime<D> implements Path<D>{
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
public PTime(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : this;
|
||||
}
|
||||
|
||||
public PTime(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
private final Path<D> pathMixin;
|
||||
|
||||
public PTime(Class<? extends D> type, Path<?> parent, @NotEmpty String property) {
|
||||
this(type, PathMetadata.forProperty(parent, property));
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Path ? ((Path<?>) o).getMetadata().equals(metadata)
|
||||
: false;
|
||||
public PTime(Class<? extends D> type, PathMetadata<?> metadata) {
|
||||
super(type);
|
||||
this.pathMixin = new PathMixin<D>(this, metadata);
|
||||
}
|
||||
|
||||
public PTime(Class<? extends D> type, @NotEmpty String var) {
|
||||
this(type, PathMetadata.forVariable(var));
|
||||
}
|
||||
@Override
|
||||
public void accept(Visitor v) {
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ETime<D> asExpr() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return pathMixin.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathMetadata<?> getMetadata() {
|
||||
return metadata;
|
||||
return pathMixin.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<?> getRoot() {
|
||||
return root;
|
||||
return pathMixin.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
return pathMixin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, this);
|
||||
}
|
||||
return isnotnull;
|
||||
return pathMixin.isNotNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, this);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ETime<D> asExpr() {
|
||||
return this;
|
||||
return pathMixin.isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,11 @@ import com.mysema.query.types.expr.Expr;
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface Path<C> {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
Expr<C> asExpr();
|
||||
|
||||
/**
|
||||
* Get the metadata for this path
|
||||
*
|
||||
@ -42,7 +47,7 @@ public interface Path<C> {
|
||||
* @return
|
||||
*/
|
||||
EBoolean isNotNull();
|
||||
|
||||
|
||||
/**
|
||||
* Create a <code>this is null</code> expression
|
||||
*
|
||||
@ -50,10 +55,5 @@ public interface Path<C> {
|
||||
* @return
|
||||
*/
|
||||
EBoolean isNull();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
Expr<C> asExpr();
|
||||
|
||||
}
|
||||
|
||||
@ -21,10 +21,10 @@ public class PathInits {
|
||||
|
||||
public static final PathInits DIRECT = new PathInits("*");
|
||||
|
||||
private final Map<String,PathInits> propertyToInits = new HashMap<String,PathInits>();
|
||||
|
||||
private boolean initAllProps = false;
|
||||
|
||||
private final Map<String,PathInits> propertyToInits = new HashMap<String,PathInits>();
|
||||
|
||||
public PathInits(String... inits){
|
||||
for (String init : inits){
|
||||
addInit(init);
|
||||
|
||||
@ -67,13 +67,13 @@ public final class PathMetadata<T> implements Serializable{
|
||||
|
||||
private final Expr<T> expression;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
@Nullable
|
||||
private final Path<?> parent, root;
|
||||
|
||||
private final PathType pathType;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
private PathMetadata(@Nullable Path<?> parent, Expr<T> expression, PathType type) {
|
||||
this.parent = parent;
|
||||
this.expression = expression;
|
||||
@ -105,10 +105,6 @@ public final class PathMetadata<T> implements Serializable{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean isRoot(){
|
||||
return parent == null;
|
||||
}
|
||||
|
||||
public PathType getPathType() {
|
||||
return pathType;
|
||||
}
|
||||
@ -122,4 +118,8 @@ public final class PathMetadata<T> implements Serializable{
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public boolean isRoot(){
|
||||
return parent == null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.Expr;
|
||||
import com.mysema.query.types.operation.OBoolean;
|
||||
import com.mysema.query.types.operation.Ops;
|
||||
|
||||
/**
|
||||
* PathMixin defines a mixin version of the Path interface which can be used
|
||||
* as a component and target in actual Path implementations
|
||||
*
|
||||
* @author tiwe
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
class PathMixin<T> implements Path<T> {
|
||||
|
||||
private volatile EBoolean isnull, isnotnull;
|
||||
|
||||
private final PathMetadata<?> metadata;
|
||||
|
||||
private final Path<?> root;
|
||||
|
||||
private final Expr<T> self;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PathMixin(Expr<T> self, PathMetadata<?> metadata){
|
||||
this.self = self;
|
||||
this.metadata = metadata;
|
||||
this.root = metadata.getRoot() != null ? metadata.getRoot() : (Path<T>)self;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expr<T> asExpr() {
|
||||
return self;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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 Class<? extends T> getType() {
|
||||
return self.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return metadata.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNotNull() {
|
||||
if (isnotnull == null) {
|
||||
isnotnull = OBoolean.create(Ops.IS_NOT_NULL, self);
|
||||
}
|
||||
return isnotnull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EBoolean isNull() {
|
||||
if (isnull == null) {
|
||||
isnull = OBoolean.create(Ops.IS_NULL, self);
|
||||
}
|
||||
return isnull;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user