public static <T> Predicate<T> toPredicate(Criterion<T> criterion) {
    Objects.requireNonNull(criterion, "criterion");
    Expression expression = Criterias.toQuery(criterion).filter().orElseThrow(() -> new IllegalArgumentException("Filter not set"));
    @SuppressWarnings("unchecked")
    Predicate<T> predicate = (Predicate<T>) ExpressionInterpreter.of(expression).asPredicate();
    return predicate;
  }
Converts criteria to a predicate. Note that filter must be set on criteria.
For instance {@code person.name.is("John")} is a valid filter but {@code person.name} is not.

@throws NullPointerException if argument is null
@throws IllegalArgumentException if filter is not set on criteria
@return predicate which reflects criteria filter expression
criteria/inmemory/src/org/immutables/criteria/inmemory/InMemory.java