AndPredicate extends CompositePredicate<T> { @Override public boolean test(T t) { return getOperands().stream().allMatch(o -> o.test(t)); } @SafeVarargs  AndPredicate(SerializablePredicate<T>... predicates); @Override boolean test(T t); @Override @SuppressWarnings("unchecked") AndPredicate<T> and(Predicate<? super T> other);  }
@Test public void test() { EqualsPredicate<TestEntity> p1 = new EqualsPredicate<>("name", "Bob"); EqualsPredicate<TestEntity> p2 = new EqualsPredicate<>("age", 44L); AndPredicate<TestEntity> and = new AndPredicate<>(p1); TestEntity t1 = new TestEntity(); t1.setName("Bob"); t1.setAge(45L); assertTrue(and.test(t1)); and = new AndPredicate<>(p1, p2); assertFalse(and.test(t1)); t1.setAge(44L); assertTrue(and.test(t1)); }