mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-24 21:07:26 +08:00
added clone and equals to Operation implementations
added equals and hashCode to JoinExpression
This commit is contained in:
parent
29ef4944a1
commit
c770144669
@ -5,7 +5,10 @@
|
||||
*/
|
||||
package com.mysema.query;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
|
||||
import com.mysema.query.grammar.types.Expr;
|
||||
import com.mysema.query.util.Assert;
|
||||
|
||||
/**
|
||||
* JoinExpression represents a join element in a Query instance
|
||||
@ -21,13 +24,13 @@ public class JoinExpression<T> {
|
||||
|
||||
public JoinExpression(JoinType type, Expr<?> target) {
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.target = Assert.notNull(target);
|
||||
this.metadata = null;
|
||||
}
|
||||
|
||||
public JoinExpression(JoinType type, Expr<?> target, T metadata) {
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.target = Assert.notNull(target);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@ -55,4 +58,23 @@ public class JoinExpression<T> {
|
||||
return type + " " + target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return target.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
if (o instanceof JoinExpression){
|
||||
JoinExpression<?> j = (JoinExpression<?>)o;
|
||||
return new EqualsBuilder()
|
||||
.append(condition, j.condition)
|
||||
.append(metadata, j.metadata)
|
||||
.append(target, j.target)
|
||||
.append(type, j.type).isEquals();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,7 +24,7 @@ import com.mysema.query.util.NumberUtil;
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class Expr<D> {
|
||||
public abstract class Expr<D>{
|
||||
|
||||
private final Class<? extends D> type;
|
||||
private String toString;
|
||||
|
||||
@ -37,7 +37,9 @@ public interface Operation<OP,RT> {
|
||||
}
|
||||
public Expr<?>[] getArgs() {return args;}
|
||||
public Op<Boolean> getOperator() {return op;}
|
||||
|
||||
public OBoolean clone(){
|
||||
return new OBoolean(op, args.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +58,10 @@ public interface Operation<OP,RT> {
|
||||
this(null, op, args);
|
||||
}
|
||||
public Expr<?>[] getArgs() {return args;}
|
||||
public Op<OpType> getOperator() {return op;}
|
||||
public Op<OpType> getOperator() {return op;}
|
||||
public OComparable<OpType,D> clone(){
|
||||
return new OComparable<OpType,D>((Class<D>)getType(), op, args.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +80,10 @@ public interface Operation<OP,RT> {
|
||||
this(null, op, args);
|
||||
}
|
||||
public Expr<?>[] getArgs() {return args;}
|
||||
public Op<OpType> getOperator() {return op;}
|
||||
public Op<OpType> getOperator() {return op;}
|
||||
public ONumber<OpType,D> clone(){
|
||||
return new ONumber<OpType,D>((Class<D>)getType(), op, args.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +98,9 @@ public interface Operation<OP,RT> {
|
||||
}
|
||||
public Expr<?>[] getArgs() {return args;}
|
||||
public Op<String> getOperator() {return op;}
|
||||
public OString clone(){
|
||||
return new OString(op, args.clone());
|
||||
}
|
||||
}
|
||||
|
||||
public static class OStringArray extends Expr<String[]> implements Operation<String,String[]>{
|
||||
@ -102,6 +113,9 @@ public interface Operation<OP,RT> {
|
||||
}
|
||||
public Expr<?>[] getArgs() {return args;}
|
||||
public Op<String> getOperator() {return op;}
|
||||
public OStringArray clone(){
|
||||
return new OStringArray(op, args.clone());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user