}
return query.addSort(sort);
}
private Criteria from(Type type, Criteria instance, Iterator<?> parameters) {
Criteria criteria = instance;
if (criteria == null) {
criteria = new Criteria();
}
switch (type) {
case TRUE:
return criteria.is(true);
case FALSE:
return criteria.is(false);
case SIMPLE_PROPERTY:
return criteria.is(appendBoostAndGetParameterValue(criteria, parameters));
case NEGATING_SIMPLE_PROPERTY:
return criteria.is(appendBoostAndGetParameterValue(criteria, parameters)).not();
case IS_NULL:
return criteria.isNull();
case IS_NOT_NULL:
return criteria.isNotNull();
case REGEX:
return criteria.expression(appendBoostAndGetParameterValue(criteria, parameters).toString());
case LIKE:
case STARTING_WITH:
return criteria.startsWith(asStringArray(appendBoostAndGetParameterValue(criteria, parameters)));
case NOT_LIKE:
return criteria.startsWith(asStringArray(appendBoostAndGetParameterValue(criteria, parameters))).not();
case ENDING_WITH:
return criteria.endsWith(asStringArray(appendBoostAndGetParameterValue(criteria, parameters)));
case CONTAINING:
return criteria.contains(asStringArray(appendBoostAndGetParameterValue(criteria, parameters)));
case AFTER:
case GREATER_THAN:
return criteria.greaterThan(appendBoostAndGetParameterValue(criteria, parameters));
case GREATER_THAN_EQUAL:
return criteria.greaterThanEqual(appendBoostAndGetParameterValue(criteria, parameters));
case BEFORE:
case LESS_THAN:
return criteria.lessThan(appendBoostAndGetParameterValue(criteria, parameters));
case LESS_THAN_EQUAL:
return criteria.lessThanEqual(appendBoostAndGetParameterValue(criteria, parameters));
case BETWEEN:
return criteria.between(appendBoostAndGetParameterValue(criteria, parameters),
appendBoostAndGetParameterValue(criteria, parameters));
case IN:
return criteria.in(asArray(appendBoostAndGetParameterValue(criteria, parameters)));
case NOT_IN:
return criteria.in(asArray(appendBoostAndGetParameterValue(criteria, parameters))).not();
case NEAR:
return createNearCriteria(parameters, criteria);
case WITHIN:
return criteria.within((Point) getBindableValue((BindableSolrParameter) parameters.next()),
(Distance) getBindableValue((BindableSolrParameter) parameters.next()));
default:
throw new InvalidDataAccessApiUsageException("Illegal criteria found '" + type + "'.");
}
}