IsNullPredicate 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); } IsNullPredicate(String property); @Override boolean test(T t);  }
@Test public void test() { IsNullPredicate<TestEntity> p1 = new IsNullPredicate<>("name"); assertFalse(p1.test(null)); TestEntity t1 = new TestEntity(); t1.setName(null); assertTrue(p1.test(t1)); t1.setName("Bob"); assertFalse(p1.test(t1)); }