InPredicate extends PropertyPredicate<T> { @Override public boolean test(final T t) { if (t == null) { return false; } Object v = ClassUtils.getFieldValue(t, getProperty()); if (v == null) { return false; } Collection<?> values = getValue(); return values.contains(v); } InPredicate(String property, Collection<?> values); @Override Collection<?> getValue(); @Override boolean test(final T t);  }
@Test public void test() { InPredicate<TestEntity> p1 = new InPredicate<TestEntity>("age", List.of(4L, 5L, 6L)); assertFalse(p1.test(null)); TestEntity t1 = new TestEntity(); t1.setAge(7L); assertFalse(p1.test(t1)); t1.setAge(4L); assertTrue(p1.test(t1)); }