Java Code Examples for com.hazelcast.query.Predicates#ilike()

The following examples show how to use com.hazelcast.query.Predicates#ilike() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
private Predicate<?, ?> fromEqualityVariant(Type type, boolean ignoreCase, String property,
                                            Iterator<Comparable<?>> iterator) {
    switch (type) {
        case SIMPLE_PROPERTY:
            if (ignoreCase) {
                return Predicates.ilike(property, iterator.next().toString());
            } else {
                return Predicates.equal(property, iterator.next());
            }
        case NEGATING_SIMPLE_PROPERTY:
            if (ignoreCase) {
                return Predicates.not(Predicates.ilike(property, iterator.next().toString()));
            } else {
                return Predicates.notEqual(property, iterator.next());
            }
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example 2
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
private Predicate<?, ?> fromLikeVariant(Type type, boolean ignoreCase, String property, Iterator<Comparable<?>> iterator) {
    String likeExpression = iterator.next().toString();
    switch (type) {
        case CONTAINING:
        case NOT_CONTAINING:
            likeExpression = String.join("", "%", likeExpression, "%");
            break;
        case STARTING_WITH:
            likeExpression = String.join("", likeExpression, "%");
            break;
        case ENDING_WITH:
            likeExpression = String.join("", "%", likeExpression);
            break;
        case LIKE:
        case NOT_LIKE:
            break;
        default:
            throw new InvalidDataAccessApiUsageException(String.format("'%s' is not supported for LIKE style query", type));
    }

    Predicate likePredicate = ignoreCase ? Predicates.ilike(property, likeExpression) : Predicates
            .like(property, likeExpression);
    return type.equals(NOT_LIKE) || type.equals(NOT_CONTAINING) ? Predicates.not(likePredicate) : likePredicate;
}