diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-07-22 15:13:01 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-07-22 15:13:01 +0200 |
commit | 6c5247f1e0b0e0a6953543c2f672c8a702f3fa3f (patch) | |
tree | a6bf5e5ae1825dd2e1597d7b7e0ca45f42bc7a0c /document/src | |
parent | 5d705fcb5eba5a6c394a86bd55165fb909ae98c2 (diff) |
Clean up code following intellij advise
Diffstat (limited to 'document/src')
3 files changed, 28 insertions, 45 deletions
diff --git a/document/src/main/java/com/yahoo/document/select/rule/ArithmeticNode.java b/document/src/main/java/com/yahoo/document/select/rule/ArithmeticNode.java index 813c3b27612..015b3f24dd8 100644 --- a/document/src/main/java/com/yahoo/document/select/rule/ArithmeticNode.java +++ b/document/src/main/java/com/yahoo/document/select/rule/ArithmeticNode.java @@ -3,7 +3,10 @@ package com.yahoo.document.select.rule; import com.yahoo.document.BucketIdFactory; import com.yahoo.document.datatypes.NumericFieldValue; -import com.yahoo.document.select.*; +import com.yahoo.document.select.BucketSet; +import com.yahoo.document.select.Context; +import com.yahoo.document.select.OrderingSpecification; +import com.yahoo.document.select.Visitor; import java.util.List; import java.util.ArrayList; @@ -21,7 +24,7 @@ public class ArithmeticNode implements ExpressionNode { public static final int DIV = 4; public static final int MUL = 5; - private final List<NodeItem> items = new ArrayList<NodeItem>(); + private final List<NodeItem> items = new ArrayList<>(); public ArithmeticNode() { // empty @@ -44,7 +47,7 @@ public class ArithmeticNode implements ExpressionNode { // Inherit doc from ExpressionNode. public Object evaluate(Context context) { StringBuilder ret = null; - Stack<ValueItem> buf = new Stack<ValueItem>(); + Stack<ValueItem> buf = new Stack<>(); for (int i = 0; i < items.size(); ++i) { NodeItem item = items.get(i); Object val = item.node.evaluate(context); @@ -183,7 +186,7 @@ public class ArithmeticNode implements ExpressionNode { public int operator; public Number value; - public ValueItem(int operator, Number value) { + ValueItem(int operator, Number value) { this.operator = operator; this.value = value; } diff --git a/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java b/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java index 13a990566e3..ba007347797 100644 --- a/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java +++ b/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java @@ -7,9 +7,13 @@ import com.yahoo.document.DocumentId; import com.yahoo.document.datatypes.FieldPathIteratorHandler; import com.yahoo.document.datatypes.NumericFieldValue; import com.yahoo.document.idstring.GroupDocIdString; -import com.yahoo.document.select.*; +import com.yahoo.document.select.BucketSet; +import com.yahoo.document.select.Context; +import com.yahoo.document.select.OrderingSpecification; +import com.yahoo.document.select.Result; +import com.yahoo.document.select.ResultList; +import com.yahoo.document.select.Visitor; -import java.util.List; import java.util.regex.Pattern; /** @@ -46,17 +50,6 @@ public class ComparisonNode implements ExpressionNode { } /** - * Sets the left hand side of this comparison. - * - * @param lhs The new left hand side. - * @return This, to allow chaining. - */ - public ComparisonNode setLHS(ExpressionNode lhs) { - this.lhs = lhs; - return this; - } - - /** * Returns the comparison operator of this. * * @return The operator. @@ -85,17 +78,6 @@ public class ComparisonNode implements ExpressionNode { return rhs; } - /** - * Sets the right hand side of this comparison. - * - * @param rhs The new right hand side. - * @return This, to allow chaining. - */ - public ComparisonNode setRHS(ExpressionNode rhs) { - this.rhs = rhs; - return this; - } - public OrderingSpecification getOrdering(IdNode lhs, LiteralNode rhs, String operator, int order) { if (lhs.getWidthBits() == -1 || lhs.getDivisionBits() == -1 || !(rhs.getValue() instanceof Long)) { return null; @@ -144,9 +126,9 @@ public class ComparisonNode implements ExpressionNode { } else if (rhs instanceof IdNode && lhs instanceof LiteralNode) { return compare(factory, (IdNode)rhs, (LiteralNode)lhs, operator); } else if (lhs instanceof SearchColumnNode && rhs instanceof LiteralNode) { - return compare(factory, (SearchColumnNode)lhs, (LiteralNode)rhs); + return compare((SearchColumnNode)lhs, (LiteralNode)rhs); } else if (rhs instanceof SearchColumnNode && lhs instanceof LiteralNode) { - return compare(factory, (SearchColumnNode)rhs, (LiteralNode)lhs); + return compare((SearchColumnNode)rhs, (LiteralNode)lhs); } } return null; @@ -155,12 +137,11 @@ public class ComparisonNode implements ExpressionNode { /** * Compares a search column node with a literal node. * - * @param factory The bucket id factory used. * @param node The search column node. * @param literal The literal node to compare to. * @return The bucket set containing the buckets covered. */ - private BucketSet compare(BucketIdFactory factory, SearchColumnNode node, LiteralNode literal) { + private BucketSet compare(SearchColumnNode node, LiteralNode literal) { Object value = literal.getValue(); int bucketCount = (int) Math.pow(2, 16); if (value instanceof Long) { @@ -211,7 +192,7 @@ public class ComparisonNode implements ExpressionNode { return null; } - // Inherit doc from Node. + @Override public Object evaluate(Context context) { Object oLeft = lhs.evaluate(context); Object oRight = rhs.evaluate(context); @@ -254,7 +235,7 @@ public class ComparisonNode implements ExpressionNode { } } - public ResultList evaluateListsTrue(AttributeNode.VariableValueList lhs, AttributeNode.VariableValueList rhs) { + private ResultList evaluateListsTrue(AttributeNode.VariableValueList lhs, AttributeNode.VariableValueList rhs) { if (lhs.size() != rhs.size()) { return new ResultList(Result.FALSE); } @@ -272,7 +253,7 @@ public class ComparisonNode implements ExpressionNode { return new ResultList(Result.TRUE); } - public ResultList evaluateListsFalse(AttributeNode.VariableValueList lhs, AttributeNode.VariableValueList rhs) { + private ResultList evaluateListsFalse(AttributeNode.VariableValueList lhs, AttributeNode.VariableValueList rhs) { ResultList lst = evaluateListsTrue(lhs, rhs); if (lst.toResult() == Result.TRUE) { return new ResultList(Result.FALSE); @@ -283,7 +264,7 @@ public class ComparisonNode implements ExpressionNode { } } - public ResultList evaluateListAndSingle(AttributeNode.VariableValueList lhs, Object rhs) { + private ResultList evaluateListAndSingle(AttributeNode.VariableValueList lhs, Object rhs) { if (rhs == null && lhs == null) { return new ResultList(Result.TRUE); } @@ -293,9 +274,9 @@ public class ComparisonNode implements ExpressionNode { } ResultList retVal = new ResultList(); - for (int i = 0; i < lhs.size(); i++) { - Result result = evaluateBool(lhs.get(i).getValue(), rhs); - retVal.add((FieldPathIteratorHandler.VariableMap)lhs.get(i).getVariables().clone(), result); + for (ResultList.VariableValue value : lhs) { + Result result = evaluateBool(value.getValue(), rhs); + retVal.add((FieldPathIteratorHandler.VariableMap)value.getVariables().clone(), result); } return retVal; @@ -444,7 +425,6 @@ public class ComparisonNode implements ExpressionNode { visitor.visit(this); } - // Inherit doc from Object. @Override public String toString() { return lhs + " " + operator + " " + rhs; diff --git a/document/src/main/java/com/yahoo/document/select/rule/LogicNode.java b/document/src/main/java/com/yahoo/document/select/rule/LogicNode.java index a7b112fac70..17f3106d2a4 100644 --- a/document/src/main/java/com/yahoo/document/select/rule/LogicNode.java +++ b/document/src/main/java/com/yahoo/document/select/rule/LogicNode.java @@ -30,7 +30,7 @@ public class LogicNode implements ExpressionNode { public static final int AND = 2; // The items contained in this. - private final List<NodeItem> items = new ArrayList<NodeItem>(); + private final List<NodeItem> items = new ArrayList<>(); /** * Construct an empty logic expression. @@ -261,7 +261,7 @@ public class LogicNode implements ExpressionNode { private int operator; private ResultList value; - public ValueItem(int operator, ResultList value) { + ValueItem(int operator, ResultList value) { this.operator = operator; this.value = value; } @@ -274,7 +274,7 @@ public class LogicNode implements ExpressionNode { private int operator; private BucketSet buckets; - public BucketItem(int operator, BucketSet buckets) { + BucketItem(int operator, BucketSet buckets) { this.operator = operator; this.buckets = buckets; } @@ -287,7 +287,7 @@ public class LogicNode implements ExpressionNode { private int operator; private OrderingSpecification ordering; - public OrderingItem(int operator, OrderingSpecification orderSpec) { + OrderingItem(int operator, OrderingSpecification orderSpec) { this.operator = operator; this.ordering = orderSpec; } @@ -300,7 +300,7 @@ public class LogicNode implements ExpressionNode { private int operator; private ExpressionNode node; - public NodeItem(int operator, ExpressionNode node) { + NodeItem(int operator, ExpressionNode node) { this.operator = operator; this.node = node; } |