Browse Source

refactor:Refactor using Change bidirectional association to unidirectional association refactor technique

pull/1008/head
Vaibhav Ramchandani 11 months ago
parent
commit
404f2bcf44
  1. 19
      json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java

19
json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java

@ -205,23 +205,28 @@ public class FilterCompiler {
return new RelationalExpressionNode(left, operator, right); return new RelationalExpressionNode(left, operator, right);
} }
private LogicalOperator readLogicalOperator(){ private LogicalOperator readLogicalOperator(CharSequence charSequence, int position) {
int begin = filter.skipBlanks().position(); int begin = position;
int end = begin+1; int end = begin + 1;
if(!filter.inBounds(end)){ if (!inBounds(charSequence, end)) {
throw new InvalidPathException("Expected boolean literal"); throw new InvalidPathException("Expected boolean literal");
} }
CharSequence logicalOperator = filter.subSequence(begin, end+1);
if(!logicalOperator.equals("||") && !logicalOperator.equals("&&")){ CharSequence logicalOperator = charSequence.subSequence(begin, end + 1);
if (!logicalOperator.equals("||") && !logicalOperator.equals("&&")) {
throw new InvalidPathException("Expected logical operator"); throw new InvalidPathException("Expected logical operator");
} }
filter.incrementPosition(logicalOperator.length());
logger.trace("LogicalOperator from {} to {} -> [{}]", begin, end, logicalOperator); logger.trace("LogicalOperator from {} to {} -> [{}]", begin, end, logicalOperator);
return LogicalOperator.fromString(logicalOperator.toString()); return LogicalOperator.fromString(logicalOperator.toString());
} }
private boolean inBounds(CharSequence charSequence, int index) {
return index >= 0 && index < charSequence.length();
}
private RelationalOperator readRelationalOperator() { private RelationalOperator readRelationalOperator() {
int begin = filter.skipBlanks().position(); int begin = filter.skipBlanks().position();

Loading…
Cancel
Save