• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IgnoreCaseType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.data.repository.query.parser.Part.IgnoreCaseType的典型用法代码示例。如果您正苦于以下问题:Java IgnoreCaseType类的具体用法?Java IgnoreCaseType怎么用?Java IgnoreCaseType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IgnoreCaseType类属于org.springframework.data.repository.query.parser.Part包,在下文中一共展示了IgnoreCaseType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: from

import org.springframework.data.repository.query.parser.Part.IgnoreCaseType; //导入依赖的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);

	}
 
开发者ID:mrfrag,项目名称:spring-data-mapdb,代码行数:60,代码来源:QueryCreator.java


示例2: buildQueryCondition

import org.springframework.data.repository.query.parser.Part.IgnoreCaseType; //导入依赖的package包/类
private String buildQueryCondition(boolean basic) {

        StringBuilder builder = new StringBuilder();
        builder.append("<trim prefix=\" where \" prefixOverrides=\"and |or \">");
        int c = 0;
        for (Iterator<PartTree.OrPart> iterator = tree.iterator(); iterator.hasNext(); ) {
            PartTree.OrPart orPart = iterator.next();
            builder.append(" or (");
            builder.append("<trim prefix=\"\" prefixOverrides=\"and |or \">");

            for (Iterator<Part> it = orPart.iterator(); it.hasNext(); ) {
                String columnName = null;
                Part part = it.next();
                MybatisPersistentProperty property = persistentEntity.getPersistentProperty(part.getProperty().getSegment());
                if (null == property) {
                    throw new MybatisQueryException("can not find property: " + part.getProperty().getSegment() + " from entity: " + persistentEntity.getName());
                }
                if (!property.isEntity()) {
                    columnName = quota(persistentEntity.getEntityName()) + "." + dialect.wrapColumnName(property.getColumnName());
                } else if (!basic) {
                    if (property.isAssociation()) {
                        Association<MybatisPersistentProperty> ass = property.getAssociation();
                        if (ass instanceof MybatisManyToOneAssociation) {
                            MybatisManyToOneAssociation association = (MybatisManyToOneAssociation) ass;

                            MybatisPersistentEntity<?> obversePersistentEntity = association.getObversePersistentEntity();
                            if (null == obversePersistentEntity) {
                                throw new MybatisQueryException("can not find obverse persistent entity.");
                            }

                            PropertyPath leaf = part.getProperty().getLeafProperty();

                            if (obversePersistentEntity.getType() == leaf.getType()) {

                                //columnName = quota(persistentEntity.getEntityName() + "." + part.getProperty().getSegment()) + "." + dialect.wrapColumnName(obversePersistentEntity.getIdProperty().getColumnName());
                                throw new UnsupportedOperationException("findBy{Association Model} Style is not support now.");

                            } else {
                                MybatisPersistentProperty leafProperty = obversePersistentEntity.getPersistentProperty(leaf.getSegment());
                                if (null == leafProperty) {
                                    throw new MybatisQueryException("can not find property: " + leaf.getSegment() + " from entity: " + obversePersistentEntity.getName());
                                }
                                columnName = quota(persistentEntity.getEntityName() + "." + part.getProperty().getSegment()) + "." + dialect.wrapColumnName(leafProperty.getColumnName());
                            }
                        } else if (ass instanceof MybatisEmbeddedAssociation) {
                            columnName = quota(persistentEntity.getEntityName()) + "." + dialect.wrapColumnName(ass.getObverse().getColumnName());
                        }
                    }
                }

                if (null == columnName) {
                    throw new MybatisQueryException("can not find property: " + part.getProperty().getSegment() + " in " + method.getName());
                }

                builder.append(" and ");

                IgnoreCaseType ignoreCaseType = part.shouldIgnoreCase();
                if (ignoreCaseType == ALWAYS || ignoreCaseType == WHEN_POSSIBLE) {
                    builder.append("upper(").append(columnName).append(")");
                } else {
                    builder.append(columnName);
                }

                builder.append(generator.buildConditionOperate(part.getType()));
                String[] properties = new String[part.getType().getNumberOfArguments()];
                for (int i = 0; i < properties.length; i++) {
                    properties[i] = resolveParameterName(c++);
                }
                builder.append(generator.buildConditionCaluse(part.getType(), ignoreCaseType, properties));
            }

            builder.append("</trim>");

            builder.append(" )");

        }
        builder.append("</trim>");
        return builder.toString();
    }
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:80,代码来源:PartTreeMybatisQuery.java


示例3: buildConditionCaluse

import org.springframework.data.repository.query.parser.Part.IgnoreCaseType; //导入依赖的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();
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:55,代码来源:MybatisMapperGenerator.java


示例4: isIgnoreCase

import org.springframework.data.repository.query.parser.Part.IgnoreCaseType; //导入依赖的package包/类
private static boolean isIgnoreCase(Part part) {
	return part.shouldIgnoreCase() != IgnoreCaseType.NEVER;
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:4,代码来源:VaultQueryCreator.java


示例5: from

import org.springframework.data.repository.query.parser.Part.IgnoreCaseType; //导入依赖的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));
		}

	}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:50,代码来源:HazelcastQueryCreator.java


示例6: addCriteria

import org.springframework.data.repository.query.parser.Part.IgnoreCaseType; //导入依赖的package包/类
protected DynamoDBQueryCriteria<T, ID> addCriteria(DynamoDBQueryCriteria<T, ID> criteria, Part part, Iterator<Object> iterator) {
	if (part.shouldIgnoreCase().equals(IgnoreCaseType.ALWAYS))
		throw new UnsupportedOperationException("Case insensitivity not supported");

	Class<?> leafNodePropertyType = part.getProperty().getLeafProperty().getType();
	
	PropertyPath leafNodePropertyPath = part.getProperty().getLeafProperty();
	String leafNodePropertyName = leafNodePropertyPath.toDotPath();
	if (leafNodePropertyName.indexOf(".") != -1)
	{
		int index = leafNodePropertyName.lastIndexOf(".");
		leafNodePropertyName = leafNodePropertyName.substring(index);
	}

	switch (part.getType()) {
	
	case IN:
		Object in = iterator.next();
		Assert.notNull(in, "Creating conditions on null parameters not supported: please specify a value for '"
				+ leafNodePropertyName + "'");
		boolean isIterable = ClassUtils.isAssignable(in.getClass(), Iterable.class);
		boolean isArray = ObjectUtils.isArray(in);
		Assert.isTrue(isIterable || isArray, "In criteria can only operate with Iterable or Array parameters");
		Iterable<?> iterable = isIterable ? ((Iterable<?>) in) : Arrays.asList(ObjectUtils.toObjectArray(in));
		return criteria.withPropertyIn(leafNodePropertyName, iterable, leafNodePropertyType);
	case CONTAINING:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.CONTAINS,
				iterator.next(), leafNodePropertyType);
	case STARTING_WITH:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.BEGINS_WITH,
				iterator.next(), leafNodePropertyType);
	case BETWEEN:
		Object first = iterator.next();
		Object second = iterator.next();
		return criteria.withPropertyBetween(leafNodePropertyName, first, second, leafNodePropertyType);
	case AFTER:
	case GREATER_THAN:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.GT, iterator.next(),
				leafNodePropertyType);
	case BEFORE:
	case LESS_THAN:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.LT, iterator.next(),
				leafNodePropertyType);
	case GREATER_THAN_EQUAL:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.GE, iterator.next(),
				leafNodePropertyType);
	case LESS_THAN_EQUAL:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.LE, iterator.next(),
				leafNodePropertyType);
	case IS_NULL:
		return criteria.withNoValuedCriteria(leafNodePropertyName, ComparisonOperator.NULL);
	case IS_NOT_NULL:
		return criteria.withNoValuedCriteria(leafNodePropertyName, ComparisonOperator.NOT_NULL);
	case TRUE:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.EQ, Boolean.TRUE,
				leafNodePropertyType);
	case FALSE:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.EQ, Boolean.FALSE,
				leafNodePropertyType);
	case SIMPLE_PROPERTY:
		return criteria.withPropertyEquals(leafNodePropertyName, iterator.next(), leafNodePropertyType);
	case NEGATING_SIMPLE_PROPERTY:
		return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.NE, iterator.next(),
				leafNodePropertyType);
	default:
		throw new IllegalArgumentException("Unsupported keyword " + part.getType());
	}

}
 
开发者ID:michaellavelle,项目名称:spring-data-dynamodb,代码行数:70,代码来源:AbstractDynamoDBQueryCreator.java



注:本文中的org.springframework.data.repository.query.parser.Part.IgnoreCaseType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DBProcMeta类代码示例发布时间:2022-05-22
下一篇:
Java SwitchState类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap