本文整理汇总了Java中org.springframework.data.repository.query.parser.Part.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.springframework.data.repository.query.parser.Part包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromInequalityVariant
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?> fromInequalityVariant(Type type, boolean ignoreCase, Iterator<Comparable<?>> iterator) {
if (ignoreCase && type != Type.SIMPLE_PROPERTY) {
throw new InvalidDataAccessApiUsageException(String.format("Ignore case not supported for '%s'", type));
}
switch (type) {
case GREATER_THAN:
return GreaterLessPredicate.gr(iterator.next());
case GREATER_THAN_EQUAL:
return GreaterLessPredicate.ge(iterator.next());
case LESS_THAN:
return GreaterLessPredicate.ls(iterator.next());
case LESS_THAN_EQUAL:
return GreaterLessPredicate.le(iterator.next());
default:
throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
}
}
示例2: getLikeTypeFrom
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
/**
* Extracts the like {@link Type} from the given JPA like expression.
*
* @param expression must not be {@literal null} or empty.
* @return
*/
private static Type getLikeTypeFrom(String expression) {
Assert.hasText(expression, "Expression must not be null or empty!");
if (expression.matches("%.*%")) {
return Type.CONTAINING;
}
if (expression.startsWith("%")) {
return Type.ENDING_WITH;
}
if (expression.endsWith("%")) {
return Type.STARTING_WITH;
}
return Type.LIKE;
}
示例3: fromInequalityVariant
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?, ?> fromInequalityVariant(Type type, boolean ignoreCase, String property,
Iterator<Comparable<?>> iterator) {
if (ignoreCase && type != Type.SIMPLE_PROPERTY) {
throw new InvalidDataAccessApiUsageException(String.format("Ignore case not supported for '%s'", type));
}
switch (type) {
case GREATER_THAN:
return Predicates.greaterThan(property, iterator.next());
case GREATER_THAN_EQUAL:
return Predicates.greaterEqual(property, iterator.next());
case LESS_THAN:
return Predicates.lessThan(property, iterator.next());
case LESS_THAN_EQUAL:
return Predicates.lessEqual(property, iterator.next());
default:
throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
}
}
示例4: fromEqualityVariant
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
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());
}
default:
throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
}
}
示例5: getParts
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
/**
* Returns all {@link GqPart}s of the {@link GqPartTree} of the given {@link Type}.
*
* @param type
* @return
*/
public Iterable<GqPart> getParts(Type type) {
List<GqPart> result = new ArrayList<GqPart>();
for (GqPart part : getParts()) {
if (part.getType().equals(type)) {
result.add(part);
}
}
return result;
}
示例6: fromBooleanVariant
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?, ?> fromBooleanVariant(Type type, String property) {
switch (type) {
case TRUE:
return Predicates.equal(property, true);
case FALSE:
return Predicates.equal(property, false);
default:
throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
}
}
示例7: fromLikeVariant
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?, ?> fromLikeVariant(Type type, String property, Iterator<Comparable<?>> iterator) {
switch (type) {
case LIKE:
return Predicates.like(property, iterator.next().toString());
default:
throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
}
}
示例8: fromNullVariant
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?, ?> fromNullVariant(Type type, String property) {
switch (type) {
case IS_NULL:
return Predicates.equal(property, null);
case IS_NOT_NULL:
return Predicates.notEqual(property, null);
default:
throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
}
}
示例9: from
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?> from(Part part, Iterator<Comparable<?>> iterator) {
String property = part.getProperty().toDotPath();
Type type = part.getType();
boolean ignoreCase = (part.shouldIgnoreCase() != IgnoreCaseType.NEVER);
Predicate<?> predicate = null;
switch (type) {
case TRUE:
predicate = new EqualsPredicate(true);
break;
case FALSE:
predicate = new EqualsPredicate(false);
break;
case SIMPLE_PROPERTY:
if (ignoreCase) {
predicate = new ILikePredicate(iterator.next().toString());
} else {
predicate = new EqualsPredicate(iterator.next());
}
break;
case GREATER_THAN:
case GREATER_THAN_EQUAL:
case LESS_THAN:
case LESS_THAN_EQUAL:
predicate = fromInequalityVariant(type, ignoreCase, iterator);
break;
case LIKE:
predicate = new LikePredicate(iterator.next().toString());
break;
case IS_NULL:
predicate = NullCheckPredicate.isNull();
break;
case IS_NOT_NULL:
predicate = NullCheckPredicate.notNull();
break;
// TODO
/*
* case AFTER: case BEFORE: case BETWEEN: case CONTAINING: case
* ENDING_WITH: case EXISTS: case IN: case NEAR: case
* NEGATING_SIMPLE_PROPERTY: case NOT_CONTAINING: case NOT_IN: case
* NOT_LIKE: case REGEX: case STARTING_WITH: case WITHIN:
*/
default:
throw new InvalidDataAccessApiUsageException(String.format("Found invalid part '%s' in query", type));
}
return PropertyPredicate.wrap(predicate, property);
}
示例10: buildConditionCaluse
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
public String buildConditionCaluse(Type type, IgnoreCaseType ignoreCaseType, String[] properties) {
StringBuilder builder = new StringBuilder();
switch (type) {
case CONTAINING:
case NOT_CONTAINING:
if (ignoreCaseType == ALWAYS || ignoreCaseType == WHEN_POSSIBLE) {
builder.append("concat('%',upper(#{" + properties[0] + "}),'%')");
} else {
builder.append("concat('%',#{" + properties[0] + "},'%')");
}
break;
case STARTING_WITH:
if (ignoreCaseType == ALWAYS || ignoreCaseType == WHEN_POSSIBLE) {
builder.append("concat(upper(#{" + properties[0] + "}),'%')");
} else {
builder.append("concat(#{" + properties[0] + "},'%')");
}
break;
case ENDING_WITH:
if (ignoreCaseType == ALWAYS || ignoreCaseType == WHEN_POSSIBLE) {
builder.append("concat('%',upper(#{" + properties[0] + "}))");
} else {
builder.append("concat('%',#{" + properties[0] + "})");
}
break;
case IN:
case NOT_IN:
builder.append("<foreach item=\"item\" index=\"index\" collection=\"" + properties[0] + "\" open=\"(\" separator=\",\" close=\")\">#{item}</foreach>");
break;
case IS_NOT_NULL:
builder.append(" is not null");
break;
case IS_NULL:
builder.append(" is null");
break;
case TRUE:
builder.append("=true");
break;
case FALSE:
builder.append("=false");
break;
default:
if (ignoreCaseType == ALWAYS || ignoreCaseType == WHEN_POSSIBLE) {
builder.append("upper(#{" + properties[0] + "})");
} else {
builder.append("#{" + properties[0] + "}");
}
break;
}
return builder.toString();
}
示例11: buildConditionOperate
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
public String buildConditionOperate(Type type) {
StringBuilder builder = new StringBuilder();
switch (type) {
case SIMPLE_PROPERTY:
builder.append("=");
break;
case NEGATING_SIMPLE_PROPERTY:
builder.append("<![CDATA[<>]]>");
break;
case LESS_THAN:
case BEFORE:
builder.append("<![CDATA[<]]>");
break;
case LESS_THAN_EQUAL:
builder.append("<![CDATA[<=]]>");
break;
case GREATER_THAN:
case AFTER:
builder.append("<![CDATA[>]]>");
break;
case GREATER_THAN_EQUAL:
builder.append("<![CDATA[>=]]>");
break;
case LIKE:
case NOT_LIKE:
case STARTING_WITH:
case ENDING_WITH:
if (type == NOT_LIKE) {
builder.append(" not");
}
builder.append(" like ");
break;
case CONTAINING:
case NOT_CONTAINING:
if (type == NOT_CONTAINING) {
builder.append(" not");
}
builder.append(" like ");
break;
case IN:
case NOT_IN:
if (type == NOT_IN) {
builder.append(" not");
}
builder.append(" in ");
break;
}
return builder.toString();
}
示例12: from
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
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 + "'.");
}
}
示例13: from
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private Predicate<?, ?> from(Part part, Iterator<Comparable<?>> iterator) {
String property = part.getProperty().toDotPath();
Type type = part.getType();
boolean ignoreCase = (part.shouldIgnoreCase() != IgnoreCaseType.NEVER);
switch (type) {
case FALSE:
case TRUE:
return fromBooleanVariant(type, property);
case SIMPLE_PROPERTY:
return fromEqualityVariant(type, ignoreCase, property, iterator);
case GREATER_THAN:
case GREATER_THAN_EQUAL:
case LESS_THAN:
case LESS_THAN_EQUAL:
return fromInequalityVariant(type, ignoreCase, property, iterator);
case LIKE:
return fromLikeVariant(type, property, iterator);
case IS_NOT_NULL:
case IS_NULL:
return fromNullVariant(type, property);
/* case AFTER:
* case BEFORE:
* case BETWEEN:
* case CONTAINING:
* case ENDING_WITH:
* case EXISTS:
* case IN:
* case NEAR:
* case NEGATING_SIMPLE_PROPERTY:
* case NOT_CONTAINING:
* case NOT_IN:
* case NOT_LIKE:
* case REGEX:
* case STARTING_WITH:
* case WITHIN:
*/
default:
throw new InvalidDataAccessApiUsageException(String.format("Found invalid part '%s' in query", type));
}
}
示例14: requiresInverseLookup
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
private static boolean requiresInverseLookup(Part part) {
return part.getType() == Type.IN;
}
示例15: ParameterMetadata
import org.springframework.data.repository.query.parser.Part.Type; //导入依赖的package包/类
/**
* Creates a new {@link ParameterMetadata}.
*
* @param parameterType
* @param parameterName
* @param type
* @param value
*/
public ParameterMetadata(Class<T> parameterType, String parameterName, Type type, Object value) {
this.parameterType = parameterType;
this.parameterName = parameterName;
this.parameterValue = value;
this.type = (value == null && Type.SIMPLE_PROPERTY.equals(type) ? Type.IS_NULL : type);
}