PredicateUtils { @SafeVarargs public static <T> Object extractPredicateValue(SerializablePredicate<T> predicate, String propertyId, Class<?>... typesToFind) { SerializablePredicate<T> extracted = extractPredicate(predicate, propertyId, typesToFind); if (extracted instanceof PropertyPredicate) { PropertyPredicate<T> prop = (PropertyPredicate<T>) extracted; return prop.getValue(); } return null; } private  PredicateUtils(); @SafeVarargs static SerializablePredicate<T> extractPredicate(SerializablePredicate<T> predicate, String propertyId,
			Class<?>... typesToFind); @SafeVarargs static Object extractPredicateValue(SerializablePredicate<T> predicate, String propertyId,
			Class<?>... typesToFind); static boolean isTrue(SerializablePredicate<T> predicate, String propertyId); static boolean isPredicateValueSet(SerializablePredicate<T> predicate, Set<String> ignore);  }
@Test public void testExtractPredicateValue_Compare() { EqualsPredicate<TestEntity> comp = new EqualsPredicate<TestEntity>("prop1", "someString"); Object value = PredicateUtils.extractPredicateValue(comp, "prop1"); assertEquals("someString", value); value = PredicateUtils.extractPredicateValue(comp, "prop2"); assertNull(value); }
@Test public void testExtractPredicateValue_Composite() { LikePredicate<TestEntity> compare = new LikePredicate<TestEntity>("prop1", "someString1", true); AndPredicate<TestEntity> and = new AndPredicate<TestEntity>(compare, new EqualsPredicate<TestEntity>("prop2", "someString2")); Object f1 = PredicateUtils.extractPredicateValue(and, "prop1"); assertEquals("someString1", f1); Object f2 = PredicateUtils.extractPredicateValue(and, "prop2"); assertEquals("someString2", f2); Object f3 = PredicateUtils.extractPredicateValue(compare, "prop3"); assertNull(f3); }