@Test public void testOrWithNullPredicateInstance(){ StreamPredicateBuilder spb = new StreamPredicateBuilder(); StreamPredicateBuilder spb2 = null; try{ spb.or(spb2); fail("should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } }
public StreamPredicateBuilder or(Predicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"or\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.or(first, second)); return this; }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder or(Predicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"or\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.or(first, second)); return this; } }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder or(Predicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"or\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.or(first, second)); return this; } StreamPredicateBuilder(); }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder or(Predicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"or\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.or(first, second)); return this; } StreamPredicateBuilder(); Attribute.Name getAttribute(); void setAttribute(Attribute.Name attributeName); @Override boolean apply(Collection<Attribute> attributes); StreamComparison getComparison(); StreamPredicateBuilder and(StreamPredicate predicate); StreamPredicateBuilder or(Predicate predicate); @Override Comparison attribute(Attribute.Name name); @Override Predicate and(Predicate... predicates); @Override Predicate or(Predicate... predicates); }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder or(Predicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"or\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.or(first, second)); return this; } StreamPredicateBuilder(); Attribute.Name getAttribute(); void setAttribute(Attribute.Name attributeName); @Override boolean apply(Collection<Attribute> attributes); StreamComparison getComparison(); StreamPredicateBuilder and(StreamPredicate predicate); StreamPredicateBuilder or(Predicate predicate); @Override Comparison attribute(Attribute.Name name); @Override Predicate and(Predicate... predicates); @Override Predicate or(Predicate... predicates);  }