/** * Factory to create the comparator predicate * * @param <T> the type that the predicate queries * @param object the object to compare to * @param comparator the comparator to use for comparison * @param criterion the criterion to use to evaluate comparison * @return the predicate * @throws NullPointerException if comparator or criterion is null */ public static <T> Predicate<T> comparatorPredicate(final T object, final Comparator<T> comparator, final Criterion criterion) { if (comparator == null) { throw new NullPointerException("Comparator must not be null."); } if (criterion == null) { throw new NullPointerException("Criterion must not be null."); } return new ComparatorPredicate<>(object, comparator, criterion); }