• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OrPart类的典型用法和代码示例

java 1次浏览

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

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

示例1: createPredicate

点赞 3

import org.springframework.data.repository.query.parser.PartTree.OrPart; //导入依赖的package包/类
private Predicate createPredicate(PathBuilder<?> builder, PartTree tree, BeanWrapper bean){
	
	//BeanWrapper paramWrapper = PropertyAccessorFactory.forBeanPropertyAccess(param);
	
	BooleanExpression base = null;
	for (OrPart node : tree) {
		//logger.debug("OrPart : "+node.getClass());
		
		BooleanExpression criteria = null;
		for (Part part : node) {
			//logger.debug("Part "+part.getClass());
			
			if(part.getProperty() != null){
				BooleanExpression newCriteria = create(builder, part, bean);
				if(newCriteria != null){
					//logger.debug("ok....");
					criteria = criteria == null ? newCriteria : and(criteria, newCriteria, bean);
				}
			}
		}
		base = base == null ? criteria : or(base, criteria, bean);
	}
	//logger.debug("base "+base);
	
	return base;
}
 

开发者ID:u2ware,
项目名称:springfield,
代码行数:27,
代码来源:QueryMethodResolver.java

示例2: doExecute

点赞 2

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

示例3: toIndexedQuery

点赞 2

import org.springframework.data.repository.query.parser.PartTree.OrPart; //导入依赖的package包/类
/**
 * Convert a {@link PartTree} into a where query alike to the one present in the
 * {@link Query}'s where property.  
 */
public static String toIndexedQuery(final PartTree tree) {
	final StringBuilder result = new StringBuilder();
	
	final Iterator<OrPart> orIt = tree.iterator();
	while(orIt.hasNext()) {
		
		final OrPart orPart = orIt.next();
		
		final Iterator<Part> partIt = orPart.iterator();
		while(partIt.hasNext()) {
			final Part part = partIt.next();
			
			result.append(" " + part.getProperty().getSegment() + " ");
			result.append(convertOperator(part.getType()));
			
			if(partIt.hasNext()) {
				result.append(" AND ");
			}
		}
		
		if(orIt.hasNext()) {
			result.append(" OR ");
		}
	}
	
	return StringUtil.removeExtraSpaces(result.toString());
}
 

开发者ID:3pillarlabs,
项目名称:spring-data-simpledb,
代码行数:32,
代码来源:PartTreeConverter.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)