Java 类org.springframework.data.repository.query.parser.Part.Type 实例源码

项目:spring-data-mapdb    文件:QueryCreator.java   
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));
        }
    }
项目:spring-data-ebean    文件:StringQuery.java   
/**
 * 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;
}
项目:spring-data-hazelcast    文件:HazelcastQueryCreator.java   
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));
    }
}
项目:spring-data-hazelcast    文件:HazelcastQueryCreator.java   
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));
    }
}
项目:ef-orm    文件:GqPartTree.java   
/**
 * 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;
}
项目:spring-data-hazelcast    文件:HazelcastQueryCreator.java   
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));
        }
    }
项目:spring-data-hazelcast    文件:HazelcastQueryCreator.java   
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));
        }
    }
项目:spring-data-hazelcast    文件:HazelcastQueryCreator.java   
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));
        }
    }
项目:spring-data-mapdb    文件:QueryCreator.java   
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);

    }
项目:spring-data-mybatis    文件:MybatisMapperGenerator.java   
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();
}
项目:spring-data-mybatis    文件:MybatisMapperGenerator.java   
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();
}
项目:dubbox-solr    文件:SolrQueryCreator.java   
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 + "'.");
    }
}
项目:spring-data-hazelcast    文件:HazelcastQueryCreator.java   
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));
        }

    }
项目:spring-data-keyvalue    文件:SpelQueryCreator.java   
private static boolean requiresInverseLookup(Part part) {
    return part.getType() == Type.IN;
}
项目:spring-data-ebean    文件:ParameterMetadataProvider.java   
/**
 * 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);
}
项目:spring-data-ebean    文件:StringQuery.java   
/**
 * Creates a new {@link LikeParameterBinding} for the parameter with the given name and {@link Type} and parameter
 * binding input.
 *
 * @param name       must not be {@literal null} or empty.
 * @param type       must not be {@literal null}.
 * @param expression may be {@literal null}.
 */
public LikeParameterBinding(String name, Type type, String expression) {

  super(name, null, expression);

  Assert.hasText(name, "Name must not be null or empty!");
  Assert.notNull(type, "Type must not be null!");

  Assert.isTrue(SUPPORTED_TYPES.contains(type),
      String.format("Type must be one of %s!", StringUtils.collectionToCommaDelimitedString(SUPPORTED_TYPES)));

  this.type = type;
}
项目:spring-data-ebean    文件:StringQuery.java   
/**
 * Creates a new {@link LikeParameterBinding} for the parameter with the given position and {@link Type}.
 *
 * @param position
 * @param type       must not be {@literal null}.
 * @param expression may be {@literal null}.
 */
public LikeParameterBinding(int position, Type type, String expression) {

  super(null, position, expression);

  Assert.isTrue(position > 0, "Position must be greater than zero!");
  Assert.notNull(type, "Type must not be null!");

  Assert.isTrue(SUPPORTED_TYPES.contains(type),
      String.format("Type must be one of %s!", StringUtils.collectionToCommaDelimitedString(SUPPORTED_TYPES)));

  this.type = type;
}
项目:spring-data-ebean    文件:ParameterMetadataProvider.java   
/**
 * Returns whether the parameter shall be considered an {@literal IS NULL} parameter.
 *
 * @return
 */
public boolean isIsNullParameter() {
  return Type.IS_NULL.equals(type);
}
项目:spring-data-ebean    文件:StringQuery.java   
/**
 * Creates a new {@link LikeParameterBinding} for the parameter with the given name and {@link Type}.
 *
 * @param name must not be {@literal null} or empty.
 * @param type must not be {@literal null}.
 */
public LikeParameterBinding(String name, Type type) {
  this(name, type, null);
}
项目:spring-data-ebean    文件:StringQuery.java   
/**
 * Creates a new {@link LikeParameterBinding} for the parameter with the given position and {@link Type}.
 *
 * @param position
 * @param type     must not be {@literal null}.
 */
public LikeParameterBinding(int position, Type type) {
  this(position, type, null);
}
项目:spring-data-ebean    文件:StringQuery.java   
/**
 * Returns the {@link Type} of the binding.
 *
 * @return the type
 */
public Type getType() {
  return type;
}