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

Java PropertyPath类代码示例

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

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



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

示例1: buildOrderPropertyPathFrom

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
private Expression<?> buildOrderPropertyPathFrom(JoinerQuery<?, ?> joinerQuery, Sort.Order order) {
    PathBuilder<?> builder = new PathBuilder<Object>(joinerQuery.getFrom().getType(), joinerQuery.getFrom().toString());

    PropertyPath path = PropertyPath.from(order.getProperty(), builder.getType());
    Expression<?> sortPropertyExpression = builder;

    while (path != null) {

        if (!path.hasNext() && order.isIgnoreCase()) {
            // if order is ignore-case we have to treat the last path segment as a String.
            sortPropertyExpression = Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower();
        } else {
            sortPropertyExpression = Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
        }

        path = path.next();
    }

    return sortPropertyExpression;
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:21,代码来源:PageableFeature.java


示例2: createLikeRegexCriteriaOrThrow

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
private Criteria createLikeRegexCriteriaOrThrow(Part part, DocumentDbPersistentProperty property,
    Criteria criteria, Iterator<Object> parameters, boolean shouldNegateExpression) {
    final PropertyPath path = part.getProperty().getLeafProperty();

    switch (part.shouldIgnoreCase()) {
        case ALWAYS:
            if (path.getType() != String.class) {
                throw new IllegalArgumentException("part must be String, but: " + path.getType() + ", " + path);
            }

            /* fall through */
        case WHEN_POSSIBLE:

            return criteria;

        case NEVER:
            break;
    }

    return null;
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:22,代码来源:DocumentDbQueryCreator.java


示例3: buildOrderPropertyPathFrom

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
/**
 * Creates an {@link Expression} for the given {@link Order} property.
 *
 * @param order must not be {@literal null}.
 * @param builder must not be {@literal null}.
 * @return
 */
private static Expression<?> buildOrderPropertyPathFrom(Order order, PathBuilder<?> builder) {

	Assert.notNull(order, "Order must not be null!");
	Assert.notNull(builder, "Builder must not be null!");

	PropertyPath path = PropertyPath.from(order.getProperty(), builder.getType());
	Expression<?> sortPropertyExpression = builder;

	while (path != null) {

		if (!path.hasNext() && order.isIgnoreCase()) {
			// if order is ignore-case we have to treat the last path segment as a String.
			sortPropertyExpression = Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower();
		} else {
			sortPropertyExpression = Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
		}

		path = path.next();
	}

	return sortPropertyExpression;
}
 
开发者ID:spring-projects,项目名称:spring-data-keyvalue,代码行数:30,代码来源:KeyValueQuerydslUtils.java


示例4: create

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
@Override
protected StructuredQuery.Filter create(Part part, Iterator<Object> parameters) {
	if (part.getType().getKeywords().contains("Equals")) {
		List<String> segments = new ArrayList<String>();
		Iterator<PropertyPath> propertyPathIter = part.getProperty().iterator();
		while (propertyPathIter.hasNext()) {
			segments.add(propertyPathIter.next().getSegment());
		}
		String property = String.join(".", segments);

		Object value = parameters.next();
		if (value == null) {
			return StructuredQuery.PropertyFilter.isNull(property);
		}
		else if (value instanceof Boolean) {
			return StructuredQuery.PropertyFilter.eq(property, (Boolean) value);
		}
		else if (value instanceof Double || value instanceof Float) {
			return StructuredQuery.PropertyFilter.eq(property,
					((Number) value).doubleValue());
		}
		else if (value instanceof Number) {
			return StructuredQuery.PropertyFilter.eq(property,
					((Number) value).longValue());
		}
		else if (value instanceof CharSequence) {
			return StructuredQuery.PropertyFilter.eq(property,
					((CharSequence) value).toString());
		}
		else {
			throw new UnsupportedOperationException(
					"Value type not supported: " + value + " : " + value.getClass());
		}
	}
	else {
		throw new UnsupportedOperationException(
				"Part type not supported: " + part.getType());
	}
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:40,代码来源:GcloudDatastoreQueryCreator.java


示例5: doExecute

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
protected Object doExecute(Object[] parameters) {
    Class<?> domainClass = queryMethod.getEntityInformation().getJavaType();
    int paramIndex = 0;
    
    PartTree tree = new PartTree(getQueryMethod().getName(), getQueryMethod().getEntityInformation().getJavaType());
    System.out.println(tree);
    
    List<Filter> orFilters = new ArrayList<Filter>();
    for (Iterator<OrPart> orPartIter = tree.iterator(); orPartIter.hasNext();) {
        OrPart orPart = orPartIter.next();
        
        List<Filter> andFilters = new ArrayList<Filter>();
        for (Iterator<Part> partIter = orPart.iterator(); partIter.hasNext();) {
            Part part = partIter.next();
            PropertyPath propertyPath  = part.getProperty();
            String propName = propertyPath.getSegment();
            Object propValue = parameters[paramIndex++];
            
            FilterOperator operator = getFilterOperation(part);
            Filter filter = new Query.FilterPredicate(propName, operator, propValue);
            andFilters.add(filter);
        }
        if (andFilters.size() == 1) {
            orFilters.add(andFilters.get(0));
        } else if (andFilters.size() >= 2){
            orFilters.add(CompositeFilterOperator.and(andFilters));
        }
    }
    
    com.googlecode.objectify.cmd.Query q = ofy().load().type(domainClass);
    if (orFilters.size() == 1) {
        q = q.filter(orFilters.get(0));
    } else if (orFilters.size() >= 2){
        q = q.filter(CompositeFilterOperator.or(orFilters));
    }
    return q.list();
}
 
开发者ID:nhuttrung,项目名称:spring-data-objectify,代码行数:38,代码来源:ObjectifyRepositoryQuery.java


示例6: GqPart

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
/**
 * Creates a new {@link GqPart} from the given method name part, the
 * {@link Class} the part originates from and the start parameter index.
 * 
 * @param source
 *            must not be {@literal null}.
 * @param clazz
 *            must not be {@literal null}.
 * @param alwaysIgnoreCase
 */
public GqPart(String source, Class<?> clazz, boolean alwaysIgnoreCase) {

    Assert.hasText(source, "Part source must not be null or emtpy!");
    Assert.notNull(clazz, "Type must not be null!");

    String partToUse = detectAndSetIgnoreCase(source);
    if (alwaysIgnoreCase && ignoreCase != IgnoreCaseType.ALWAYS) {
        this.ignoreCase = IgnoreCaseType.WHEN_POSSIBLE;
    }
    this.type = Type.fromProperty(partToUse);
    this.propertyPath = PropertyPath.from(type.extractProperty(partToUse), clazz);
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:23,代码来源:GqPart.java


示例7: build

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
/**
     * Builds a Ebean {@link Expression} from the underlying {@link Part}.
     *
     * @return
     */
    public Expression build() {
      PropertyPath property = part.getProperty();
      Part.Type type = part.getType();

      switch (type) {
        case BETWEEN:
          ParameterMetadataProvider.ParameterMetadata<Comparable> first = provider.next(part);
          ParameterMetadataProvider.ParameterMetadata<Comparable> second = provider.next(part);
          return Expr.between(property.toDotPath(), first.getParameterValue(), second.getParameterValue());
        case AFTER:
        case GREATER_THAN:
          return Expr.gt(property.toDotPath(), provider.next(part).getParameterValue());
        case GREATER_THAN_EQUAL:
          return Expr.ge(property.toDotPath(), provider.next(part).getParameterValue());
        case BEFORE:
        case LESS_THAN:
          return Expr.lt(property.toDotPath(), provider.next(part).getParameterValue());
        case LESS_THAN_EQUAL:
          return Expr.le(property.toDotPath(), provider.next(part).getParameterValue());
        case IS_NULL:
          return Expr.isNull(property.toDotPath());
        case IS_NOT_NULL:
          return Expr.isNotNull(property.toDotPath());
        case NOT_IN:
          ParameterMetadataProvider.ParameterMetadata<? extends Collection> pmNotIn = provider.next(part, Collection.class);
          return Expr.not(Expr.in(property.toDotPath(), ParameterMetadataProvider.ParameterMetadata.toCollection(pmNotIn.getParameterValue())));
        case IN:
          ParameterMetadataProvider.ParameterMetadata<? extends Collection> pmIn = provider.next(part, Collection.class);
          return Expr.in(property.toDotPath(), ParameterMetadataProvider.ParameterMetadata.toCollection(pmIn.getParameterValue()));
        case STARTING_WITH:
          return Expr.startsWith(property.toDotPath(), (String) provider.next(part).getParameterValue());
        case ENDING_WITH:
          return Expr.endsWith(property.toDotPath(), (String) provider.next(part).getParameterValue());
        case CONTAINING:
          return Expr.contains(property.toDotPath(), (String) provider.next(part).getParameterValue());
        case NOT_CONTAINING:
          return Expr.not(Expr.contains(property.toDotPath(), (String) provider.next(part).getParameterValue()));
        case LIKE:
          return Expr.like(property.toDotPath(), (String) provider.next(part).getParameterValue());
        case NOT_LIKE:
          return Expr.not(Expr.like(property.toDotPath(), (String) provider.next(part).getParameterValue()));
        case TRUE:
          return Expr.eq(property.toDotPath(), true);
        case FALSE:
          return Expr.eq(property.toDotPath(), false);
        case SIMPLE_PROPERTY:
          ParameterMetadataProvider.ParameterMetadata<Object> pmEquals = provider.next(part);
          return pmEquals.isIsNullParameter() ? Expr.isNull(property.toDotPath())
              : Expr.eq(property.toDotPath(), pmEquals.getParameterValue());
        case NEGATING_SIMPLE_PROPERTY:
          ParameterMetadataProvider.ParameterMetadata<Object> pmNot = provider.next(part);
          return pmNot.isIsNullParameter() ? Expr.isNull(property.toDotPath())
              : Expr.ne(property.toDotPath(), pmNot.getParameterValue());
//				case IS_EMPTY:
//					return root.isEmpty(part.getProperty().getSegment());
//				case IS_NOT_EMPTY:
//					return root.isEmpty(part.getProperty().getSegment());
        default:
          throw new IllegalArgumentException("Unsupported keyword " + type);
      }
    }
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:67,代码来源:EbeanQueryCreator.java


示例8: buildQueryCondition

import org.springframework.data.mapping.PropertyPath; //导入依赖的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


示例9: getProperty

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
/**
 * @return the propertyPath
 */
public PropertyPath getProperty() {

    return propertyPath;
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:8,代码来源:GqPart.java


示例10: createQuery

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
private Query<?> createQuery(Object[] values, boolean withPageSort) {
	Query<?> q = QB.create(metadata);
	ParametersParameterAccessor accessor = new ParametersParameterAccessor(
			parameters, values);
	Or or = new Or();
	int index = 0;
	for (GqOrPart node : tree) {
		And and = new And();
		for (GqPart part : node) {
			PropertyPath path = part.getProperty();
			if (path.getOwningType().getType() != metadata.getThisType()) {
				throw new IllegalArgumentException("PathType:"
						+ path.getOwningType().getType() + "  metadata:"
						+ metadata.getThisType());
			}
			String fieldName = path.getSegment();
			ColumnMapping field = metadata.findField(fieldName);
			PairIO<GqParameter> paramInfo = getBindParamIndex(index++,
					fieldName);
			Object obj = accessor.getBindableValue(paramInfo.first);
			if (field != null) {
				IgnoreIf ignore = paramInfo.second.getIgnoreIf();
				if (ignore == null || !QueryUtils.isIgnore(ignore, obj)) {
					add(and, part, field.field(), obj);
				}
			}
		}
		or.addCondition(and);
	}
	q.addCondition(or);

	if (withPageSort) {
		Sort sort = tree.getSort();
		if (accessor.getSort() != null) {
			sort = accessor.getSort();
		}
		Pageable page = accessor.getPageable();
		if (page != null && page.getSort() != null) {
			sort = page.getSort();
		}
		if (sort != null)
			setSortToSpec(q, sort, metadata);
	}
	return q;
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:46,代码来源:GqPartTreeQuery.java


示例11: addCriteria

import org.springframework.data.mapping.PropertyPath; //导入依赖的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


示例12: createOrder

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
/**
 * Creates an {@link Order} instance from the given property source, direction and domain class. If the domain class
 * is given, we will use it for nested property traversal checks.
 * 
 * @param propertySource
 * @param direction
 * @param domainClass can be {@literal null}.
 * @return
 * @see PropertyPath#from(String, Class)
 */
private Order createOrder(String propertySource, Direction direction, Class<?> domainClass) {

    if (null == domainClass) {
        return new Order(direction, StringUtils.uncapitalize(propertySource));
    }
    PropertyPath propertyPath = PropertyPath.from(propertySource, domainClass);
    return new Order(direction, propertyPath.toDotPath());
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:19,代码来源:GqOrderBySource.java


示例13: getPersistentPropertyPath

import org.springframework.data.mapping.PropertyPath; //导入依赖的package包/类
/**
 * Gets persistent property path.
 *
 * @param propertyPath
 *     the property path
 * @return the persistent property path
 */
@Override
public PersistentPropertyPath<MongoPersistentProperty> getPersistentPropertyPath(PropertyPath propertyPath) {
  return getPersistentPropertyPath(propertyPath.toDotPath(), propertyPath.getOwningType().getType());
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:12,代码来源:JspressoMongoMappingContext.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RichGroupReduceFunction类代码示例发布时间:2022-05-22
下一篇:
Java MetadataMBeanInfoAssembler类代码示例发布时间: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