ColumnRanges { public static ColumnRanges rangeAtNode(ConditionExpression node) { if (node instanceof ComparisonCondition) { ComparisonCondition comparisonCondition = (ComparisonCondition) node; return comparisonToRange(comparisonCondition); } else if (node instanceof LogicalFunctionCondition) { LogicalFunctionCondition condition = (LogicalFunctionCondition) node; if (condition.getOperands().size() != 2) return null; ColumnRanges leftRange = rangeAtNode(condition.getLeft()); ColumnRanges rightRange = rangeAtNode(condition.getRight()); if (leftRange != null && rightRange != null) { List<RangeSegment> combinedSegments = combineBool(leftRange, rightRange, condition.getFunction()); if (combinedSegments != null) { return new ColumnRanges(leftRange.getColumnExpression(), condition, combinedSegments); } } } else if (node instanceof FunctionCondition) { FunctionCondition condition = (FunctionCondition) node; if ("isNull".equals(condition.getFunction())) { if (condition.getOperands().size() == 1) { ExpressionNode operand = condition.getOperands().get(0); if (operand instanceof ColumnExpression) { ColumnExpression operandColumn = (ColumnExpression) operand; return new ColumnRanges(operandColumn, condition, Collections.singletonList(RangeSegment.onlyNull(operandColumn))); } } } } else if (node instanceof InListCondition) { InListCondition inListCondition = (InListCondition) node; return inListToRange(inListCondition); } return null; } ColumnRanges(ColumnExpression columnExpression, Set<? extends ConditionExpression> rootConditions,
                        List<RangeSegment> segments);  ColumnRanges(ColumnExpression columnExpression, ConditionExpression rootCondition,
                        List<RangeSegment> segments); static ColumnRanges rangeAtNode(ConditionExpression node); static ColumnRanges andRanges(ColumnRanges left, ColumnRanges right); Collection<? extends ConditionExpression> getConditions(); List<RangeSegment> getSegments(); ColumnExpression getColumnExpression(); String describeRanges(); boolean isAllSingle(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void notColLtValue() { ConstantExpression value = constant("joe"); ConditionExpression compare = not(compare(value, Comparison.LT, firstName)); ColumnRanges expected = null; assertEquals(expected, ColumnRanges.rangeAtNode(compare)); }
@Test public void differentColumns() { ConditionExpression firstNameLtJoe = compare(firstName, Comparison.LT, constant("joe")); ConditionExpression lastNameLtSmith = compare(lastName, Comparison.LT, constant("smith")); ConditionExpression either = or(firstNameLtJoe, lastNameLtSmith); ColumnRanges expected = null; assertEquals(expected, ColumnRanges.rangeAtNode(either)); }
@Test public void sinOfColumn() { ConditionExpression isNull = sin(firstName); ColumnRanges expected = null; assertEquals(expected, ColumnRanges.rangeAtNode(isNull)); }