@Test public void testRangeNodeOr() { RangeNode<Long> rangeNode1 = new RangeNode<>("table", "column"); rangeNode1.getRangeList().addAllRanges(new Range<>(1l, 5l), new Range<>(7l, 10l), new Range<>(13l, 18l)); RangeNode<Long> rangeNode2 = new RangeNode<>("table", "column"); rangeNode2.getRangeList().addAllRanges(new Range<>(8l, 9l), new Range<>(15l, 20l), new Range<>(22l, 25l), new Range<>(2l, 6l)); RangeNode<Long> actual = rangeOperations.rangeNodeOr(rangeNode1, rangeNode2); RangeNode<Long> expected = new RangeNode<>("table", "column"); expected.getRangeList().addAllRanges(new Range<>(1l, 6l), new Range<>(7l, 10l), new Range<>(13l, 20l), new Range<>(22l, 25l)); assertEquals(expected, actual); }
public RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right) { RangeNode<T> resultNode = new RangeNode<T>(left.getTable(), left.getColumn()); RangeList<T> resultRange = new RangeList<>(); for (Range<T> r1 : left.getRangeList().getRanges()) { for (Range<T> r2 : right.getRangeList().getRanges()) { RangeList<T> combinedRange = or(r1, r2); resultRange.addAllRanges(combinedRange.getRanges()); } } resultNode.getRangeList().addAllRanges(processOrList(resultRange.getRanges())); return resultNode; }
RangeOperations { public RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right) { RangeNode<T> resultNode = new RangeNode<T>(left.getTable(), left.getColumn()); RangeList<T> resultRange = new RangeList<>(); for (Range<T> r1 : left.getRangeList().getRanges()) { for (Range<T> r2 : right.getRangeList().getRanges()) { RangeList<T> combinedRange = or(r1, r2); resultRange.addAllRanges(combinedRange.getRanges()); } } resultNode.getRangeList().addAllRanges(processOrList(resultRange.getRanges())); return resultNode; } }
RangeOperations { public RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right) { RangeNode<T> resultNode = new RangeNode<T>(left.getTable(), left.getColumn()); RangeList<T> resultRange = new RangeList<>(); for (Range<T> r1 : left.getRangeList().getRanges()) { for (Range<T> r2 : right.getRangeList().getRanges()) { RangeList<T> combinedRange = or(r1, r2); resultRange.addAllRanges(combinedRange.getRanges()); } } resultNode.getRangeList().addAllRanges(processOrList(resultRange.getRanges())); return resultNode; }  }
RangeOperations { public RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right) { RangeNode<T> resultNode = new RangeNode<T>(left.getTable(), left.getColumn()); RangeList<T> resultRange = new RangeList<>(); for (Range<T> r1 : left.getRangeList().getRanges()) { for (Range<T> r2 : right.getRangeList().getRanges()) { RangeList<T> combinedRange = or(r1, r2); resultRange.addAllRanges(combinedRange.getRanges()); } } resultNode.getRangeList().addAllRanges(processOrList(resultRange.getRanges())); return resultNode; }  RangeList<T> and(Range<T> r1, Range<T> r2); RangeList<T> or(Range<T> r1, Range<T> r2); RangeNode<T> processFilterItem(FilterItem filterItem, String table, String columnName); RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right); RangeNode<T> rangeNodeAnd(RangeNode<T> left, RangeNode<T> right); @SuppressWarnings("unchecked") RangeNode<T> processRangeNodes(RangeNode<?> left, RangeNode<?> right, LogicalOperation logicalOperation); abstract T getValue(String valueString); abstract T getMinValue(); abstract T getMaxValue(); abstract T add(T value, int step); abstract T subtract(T value, int step); }
RangeOperations { public RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right) { RangeNode<T> resultNode = new RangeNode<T>(left.getTable(), left.getColumn()); RangeList<T> resultRange = new RangeList<>(); for (Range<T> r1 : left.getRangeList().getRanges()) { for (Range<T> r2 : right.getRangeList().getRanges()) { RangeList<T> combinedRange = or(r1, r2); resultRange.addAllRanges(combinedRange.getRanges()); } } resultNode.getRangeList().addAllRanges(processOrList(resultRange.getRanges())); return resultNode; }  RangeList<T> and(Range<T> r1, Range<T> r2); RangeList<T> or(Range<T> r1, Range<T> r2); RangeNode<T> processFilterItem(FilterItem filterItem, String table, String columnName); RangeNode<T> rangeNodeOr(RangeNode<T> left, RangeNode<T> right); RangeNode<T> rangeNodeAnd(RangeNode<T> left, RangeNode<T> right); @SuppressWarnings("unchecked") RangeNode<T> processRangeNodes(RangeNode<?> left, RangeNode<?> right, LogicalOperation logicalOperation); abstract T getValue(String valueString); abstract T getMinValue(); abstract T getMaxValue(); abstract T add(T value, int step); abstract T subtract(T value, int step);  }