@Test public void simplifyForUnion() { ConstraintImpl op1, op2, op3, op4, or; Set<ConstraintImpl> expected; op1 = mock(ComparisonImpl.class); op2 = mock(ComparisonImpl.class); or = new OrImpl(op1, op2); expected = of(op1, op2); assertThat(or.convertToUnion(), is(expected)); op1 = mock(ComparisonImpl.class); op2 = mock(ComparisonImpl.class); op3 = mock(ComparisonImpl.class); or = new OrImpl(new OrImpl(op1, op2), op3); expected = of(op1, op2, op3); assertThat(or.convertToUnion(), is(expected)); op1 = mock(ComparisonImpl.class); op2 = mock(ComparisonImpl.class); op3 = mock(ComparisonImpl.class); op4 = mock(ComparisonImpl.class); or = new OrImpl(new OrImpl(new OrImpl(op1, op4), op2), op3); expected = of(op1, op2, op3, op4); assertThat(or.convertToUnion(), is(expected)); }
@Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; }
OrImpl extends ConstraintImpl { @Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; } }
OrImpl extends ConstraintImpl { @Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; } OrImpl(List<ConstraintImpl> constraints);  OrImpl(ConstraintImpl constraint1, ConstraintImpl constraint2); }
OrImpl extends ConstraintImpl { @Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; } OrImpl(List<ConstraintImpl> constraints);  OrImpl(ConstraintImpl constraint1, ConstraintImpl constraint2); List<ConstraintImpl> getConstraints(); @Override ConstraintImpl simplify(); @Override Set<PropertyExistenceImpl> getPropertyExistenceConditions(); @Override FullTextExpression getFullTextConstraint(SelectorImpl s); @Override Set<SelectorImpl> getSelectors(); @Override boolean evaluate(); @Override boolean evaluateStop(); @Override void restrict(FilterImpl f); @Override void restrictPushDown(SelectorImpl s); @Override String toString(); @Override boolean equals(Object that); @Override int hashCode(); @Override AstElement copyOf(); @Override Set<ConstraintImpl> convertToUnion(); @Override boolean requiresFullTextIndex(); @Override boolean containsUnfilteredFullTextCondition(); }
OrImpl extends ConstraintImpl { @Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; } OrImpl(List<ConstraintImpl> constraints);  OrImpl(ConstraintImpl constraint1, ConstraintImpl constraint2); List<ConstraintImpl> getConstraints(); @Override ConstraintImpl simplify(); @Override Set<PropertyExistenceImpl> getPropertyExistenceConditions(); @Override FullTextExpression getFullTextConstraint(SelectorImpl s); @Override Set<SelectorImpl> getSelectors(); @Override boolean evaluate(); @Override boolean evaluateStop(); @Override void restrict(FilterImpl f); @Override void restrictPushDown(SelectorImpl s); @Override String toString(); @Override boolean equals(Object that); @Override int hashCode(); @Override AstElement copyOf(); @Override Set<ConstraintImpl> convertToUnion(); @Override boolean requiresFullTextIndex(); @Override boolean containsUnfilteredFullTextCondition();  }