mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#566 - Refactor internals - SpiExpression, add prepareExpression() to merge queryAutoTuneHash() and queryPlanHash() - sameByPlan() & sameByBind()
This commit is contained in:
1 parent
165d4aca92
commit
3d91a4f927
72 files changed
+3119
-339
No files matched your search
@@ -26,6 +26,12 @@ abstract class LogicExpression implements SpiExpression {
|
||||
And(Expression expOne, Expression expTwo) {
|
||||
super(AND, expOne, expTwo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpression copyForPlanKey() {
|
||||
return new And(expOne.copyForPlanKey(), expTwo.copyForPlanKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class Or extends LogicExpression {
|
||||
@@ -35,11 +41,16 @@ abstract class LogicExpression implements SpiExpression {
|
||||
Or(Expression expOne, Expression expTwo) {
|
||||
super(OR, expOne, expTwo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpression copyForPlanKey() {
|
||||
return new Or(expOne.copyForPlanKey(), expTwo.copyForPlanKey());
|
||||
}
|
||||
}
|
||||
|
||||
private final SpiExpression expOne;
|
||||
protected final SpiExpression expOne;
|
||||
|
||||
private final SpiExpression expTwo;
|
||||
protected final SpiExpression expTwo;
|
||||
|
||||
private final String joinType;
|
||||
|
||||
@@ -49,6 +60,7 @@ abstract class LogicExpression implements SpiExpression {
|
||||
this.expTwo = (SpiExpression) expTwo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
expOne.containsMany(desc, manyWhereJoin);
|
||||
expTwo.containsMany(desc, manyWhereJoin);
|
||||
@@ -60,11 +72,13 @@ abstract class LogicExpression implements SpiExpression {
|
||||
expTwo.validate(validation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
expOne.addBindValues(request);
|
||||
expTwo.addBindValues(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
request.append("(");
|
||||
@@ -83,16 +97,38 @@ abstract class LogicExpression implements SpiExpression {
|
||||
/**
|
||||
* Based on the joinType plus the two expressions.
|
||||
*/
|
||||
@Override
|
||||
public void queryPlanHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(LogicExpression.class).add(joinType);
|
||||
expOne.queryPlanHash(builder);
|
||||
expTwo.queryPlanHash(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
int hc = expOne.queryBindHash();
|
||||
hc = hc * 31 + expTwo.queryBindHash();
|
||||
return hc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameByPlan(SpiExpression other) {
|
||||
|
||||
if (!(other instanceof LogicExpression)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LogicExpression that = (LogicExpression) other;
|
||||
return this.joinType.equals(that.joinType)
|
||||
&& this.expOne.isSameByPlan(that.expOne)
|
||||
&& this.expTwo.isSameByPlan(that.expTwo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
LogicExpression that = (LogicExpression) other;
|
||||
return this.expOne.isSameByBind(that.expOne)
|
||||
&& this.expTwo.isSameByBind(that.expTwo);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user