@Test public void testStreamPredicateBuilderAndWithMultiPredicate() { StreamPredicateBuilder spb = new StreamPredicateBuilder(); try{ spb.and(null, null); fail("should throw unsupported operation exception"); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } }
public StreamPredicateBuilder and(StreamPredicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"and\" 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.and(first, second)); return this; }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder and(StreamPredicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"and\" 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.and(first, second)); return this; } }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder and(StreamPredicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"and\" 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.and(first, second)); return this; } StreamPredicateBuilder(); }
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder and(StreamPredicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"and\" 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.and(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 and(StreamPredicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"and\" 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.and(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);  }