EqualsPredicate extends ComparePredicate<T> { @Override public boolean test(T t) { if (t == null) { return false; } Object v = ClassUtils.getFieldValue(t, getProperty()); return Objects.equals(getValue(), v); } EqualsPredicate(String property, Object value); @Override boolean test(T t);  }
@Test public void test() { EqualsPredicate<TestEntity> predicate = new EqualsPredicate<TestEntity>("name", "Bob"); assertFalse(predicate.test(null)); TestEntity t1 = new TestEntity(); t1.setName("Bob"); assertTrue(predicate.test(t1)); t1.setName("Kevin"); assertFalse(predicate.test(t1)); }