DataSourceUtils { public static Optional<BooleanExpression> intersectConditions(Optional<BooleanExpression> left, Optional<BooleanExpression> right) { if (!left.isPresent()) { return right; } if (!right.isPresent()) { return left; } return Optional.of(new BinaryBooleanExpression(left.get(), BinaryBooleanOperator.AND, right.get())); }  static DataSource getTail(DataSource dataSource); static void addToDataSource(DataSource parent, DataSource child); static void checkLeftDataSource(DataSource dataSource); static void checkLeftDataSource(DataSource dataSource, boolean conditionRequired); static void checkRightDataSource(DataSource dataSource); static void checkRightDataSource(DataSource dataSource, boolean conditionRequired); static Set<T> intersection(Set<T> first, Set<T> second); static Set<T> difference(Set<T> first, Set<T> second); static Optional<BooleanExpression> intersectConditions(Optional<BooleanExpression> left, Optional<BooleanExpression> right); static void iterateDataSource(DataSource dataSource, DataSourceAction action); static void crossProduct(List<I> left, List<I> right, Function<I, List<O>> transformer, BiConsumer<Pair<Integer, Integer>, List<O>> rowConsumer); static List<List<T>> crossProduct(List<Collection<T>> lists);  }
@Test public void testIntersectConditions() { Optional<BooleanExpression> left = Optional.of(new LiteralBooleanExpression(true)); Optional<BooleanExpression> right = Optional.of(new LiteralBooleanExpression(false)); assertThat(intersectConditions(left, Optional.empty()), equalTo(left)); assertThat(intersectConditions(Optional.empty(), right), equalTo(right)); assertThat(intersectConditions(left, right), equalTo(Optional.of( new BinaryBooleanExpression(left.get(), AND, right.get()) ))); }