#2366 - Rename methods with deprecation for QueryPlanCapture and Pairs

This commit is contained in:
rbygrave
2021-09-15 11:22:25 +12:00
parent f3dbf216d2
commit 0206921eae
5 changed files with 44 additions and 15 deletions
+22 -9
View File
@@ -3,6 +3,7 @@ package io.ebean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* Holds a list of value object pairs.
@@ -62,15 +63,14 @@ import java.util.List;
* </p>
* <pre>{@code sql
*
* create index ix_name on table_name ((sku || '-' || code));
* create index ix_name on table_name (sku || '-' || code);
*
* }</pre>
*/
public class Pairs {
public final class Pairs {
private final String property0;
private final String property1;
private final List<Entry> entries = new ArrayList<>();
/**
@@ -139,11 +139,19 @@ public class Pairs {
/**
* Set the separator character used with DB varchar concatenation to combine the 2 values.
*/
public Pairs setConcatSeparator(String concatSeparator) {
public Pairs concatSeparator(String concatSeparator) {
this.concatSeparator = concatSeparator;
return this;
}
/**
* Deprecated migrate to concatSeparator()
*/
@Deprecated
public Pairs setConcatSeparator(String concatSeparator) {
return concatSeparator(concatSeparator);
}
/**
* Return a suffix used with DB varchar concatenation to combine the 2 values.
*/
@@ -154,11 +162,19 @@ public class Pairs {
/**
* Add a suffix used with DB varchar concatenation to combine the 2 values.
*/
public Pairs setConcatSuffix(String concatSuffix) {
public Pairs concatSuffix(String concatSuffix) {
this.concatSuffix = concatSuffix;
return this;
}
/**
* Deprecated migrate to concatSuffix()
*/
@Deprecated
public Pairs setConcatSuffix(String concatSuffix) {
return concatSuffix(concatSuffix);
}
@Override
public String toString() {
return "p0:" + property0 + " p1:" + property1 + " entries:" + entries;
@@ -208,16 +224,13 @@ public class Pairs {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Entry that = (Entry) o;
return a.equals(that.a) && b.equals(that.b);
}
@Override
public int hashCode() {
int result = a.hashCode();
result = 92821 * result + b.hashCode();
return result;
return Objects.hash(a, b);
}
}
}
@@ -21,6 +21,14 @@ public class QueryPlanCapture {
/**
* Return the database the plans were captured for.
*/
public Database database() {
return database;
}
/**
* Deprecated migrate to database().
*/
@Deprecated
public Database getDatabase() {
return database;
}
@@ -28,6 +36,14 @@ public class QueryPlanCapture {
/**
* Return the captured query plans.
*/
public List<MetaQueryPlan> plans() {
return plans;
}
/**
* Deprecated migrate to plans().
*/
@Deprecated
public List<MetaQueryPlan> getPlans() {
return plans;
}
@@ -15,8 +15,8 @@ final class DefaultQueryPlanListener implements QueryPlanListener {
@Override
public void process(QueryPlanCapture capture) {
// better to log this in JSON form?
String dbName = capture.getDatabase().name();
for (MetaQueryPlan plan : capture.getPlans()) {
String dbName = capture.database().name();
for (MetaQueryPlan plan : capture.plans()) {
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
plan.sql(), plan.bind(), plan.plan());
@@ -77,7 +77,7 @@ public class InPairsExpressionTest extends BaseExpressionTest {
public void diffSeparator_diff() throws Exception {
InPairsExpression e0 = new InPairsExpression(pairs(), false);
InPairsExpression e1 = new InPairsExpression(pairs().setConcatSeparator(":"), false);
InPairsExpression e1 = new InPairsExpression(pairs().concatSeparator(":"), false);
different(e0, e1);
}
@@ -85,7 +85,7 @@ public class InPairsExpressionTest extends BaseExpressionTest {
public void diffSuffix_diff() throws Exception {
InPairsExpression e0 = new InPairsExpression(pairs(), false);
InPairsExpression e1 = new InPairsExpression(pairs().setConcatSuffix(":"), false);
InPairsExpression e1 = new InPairsExpression(pairs().concatSuffix(":"), false);
different(e0, e1);
}
@@ -386,8 +386,8 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
loadSomeIntoCache();
Pairs pairs = new Pairs("sku", "code")
.setConcatSeparator(":")
.setConcatSuffix("-foo")
.concatSeparator(":")
.concatSuffix("-foo")
.add("2", 1000)
.add("2", 1001)
.add("3", 1000);