ContainsPredicate extends PropertyPredicate<T> { @Override @SuppressWarnings("unchecked") public boolean test(final T t) { if (t == null) { return false; } Object v = ClassUtils.getFieldValue(t, getProperty()); if (!(v instanceof Collection)) { throw new IllegalArgumentException( "Property: " + getProperty() + " of class: " + t.getClass().toString() + " is not a Collection"); } return ((Collection<T>) v).contains(getValue()); } ContainsPredicate(final String property, final Object value); @Override @SuppressWarnings("unchecked") boolean test(final T t);  }
@Test public void test() { ContainsPredicate<TestEntity> p1 = new ContainsPredicate<>("intTags", 4); assertFalse(p1.test(null)); TestEntity t1 = new TestEntity(); assertFalse(p1.test(t1)); t1.getIntTags().add(5); assertFalse(p1.test(t1)); t1.getIntTags().add(4); assertTrue(p1.test(t1)); }