当前位置: 首页>>代码示例>>Java>>正文


Java PredicateUtils类代码示例

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


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

示例1: getPredicate

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
private Predicate getPredicate(ExtendedProperties properties, List<Predicate> predicates, String keyPreffix) {
    String key = keyPreffix + ".predicate.join";
    String operator = properties.getString(key, "all");
    String[] operators = new String[]{"all", "any", "none", "one"};
    int i = ArrayUtils.indexOf(operators, operator.toLowerCase());
    switch (i) {
        case 1:
            return PredicateUtils.anyPredicate(predicates);
        case 2:
            return PredicateUtils.nonePredicate(predicates);
        case 3:
            return PredicateUtils.onePredicate(predicates);
        default:
            return PredicateUtils.allPredicate(predicates);
    }
}
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:17,代码来源:Writer.java

示例2: getJobExtensions

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static DescribableList<GhprcExtension, GhprcExtensionDescriptor> getJobExtensions(GhprcTrigger trigger, Class<?> ...types) {
    
    // First get all global extensions
    DescribableList<GhprcExtension, GhprcExtensionDescriptor> copied = copyExtensions(trigger.getDescriptor().getExtensions());
    
    // Remove extensions that are specified by job
    filterList(copied, PredicateUtils.notPredicate(InstanceofPredicate.getInstance(GhprcProjectExtension.class)));
    
    // Then get the rest of the extensions from the job
    copied = copyExtensions(copied, trigger.getExtensions());
    
    // Filter extensions by desired interface
    filterList(copied, PredicateUtils.anyPredicate(createPredicate(types)));
    return copied;
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:17,代码来源:Ghprc.java

示例3: getAgentsByApplicationNameWithoutStatus

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
@Override
public Set<AgentInfo> getAgentsByApplicationNameWithoutStatus(String applicationName, long timestamp) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    if (timestamp < 0) {
        throw new IllegalArgumentException("timestamp must not be less than 0");
    }

    List<String> agentIds = this.applicationIndexDao.selectAgentIds(applicationName);
    List<AgentInfo> agentInfos = this.agentInfoDao.getAgentInfos(agentIds, timestamp);
    CollectionUtils.filter(agentInfos, PredicateUtils.notNullPredicate());
    if (CollectionUtils.isEmpty(agentInfos)) {
        return Collections.emptySet();
    }
    return new HashSet<>(agentInfos);
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:18,代码来源:AgentInfoServiceImpl.java

示例4: searchList

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
/**
 * A naive "search" that lists the objects, then filters them.
 * This is not an efficient search technique and should be avoided 
 * in favor of the solr-base search method
 * @deprecated
 */
private String searchList(String query) throws Exception {
	
	JSONObject results = new JSONObject();
	
	String annotationsContent = this.index();
	JSONArray annotations = (JSONArray) JSONValue.parse(annotationsContent);
	
	Collection<Predicate> predicates = new ArrayList<Predicate>();
	List<NameValuePair> criteria = URLEncodedUtils.parse(query, Charset.forName(DEFAULT_ENCODING));
	for (NameValuePair pair: criteria) {
		if (pair.getName().equals("limit") || pair.getName().equals("offset")) {
			continue;
		}
		// otherwise add the criteria
		predicates.add(new AnnotationPredicate(pair.getName(), pair.getValue()));
		
	}
	Predicate allPredicate = PredicateUtils.allPredicate(predicates);
	CollectionUtils.filter(annotations, allPredicate);
	
	results.put("total", annotations.size());
	results.put("rows", annotations);
	
	return results.toJSONString();
}
 
开发者ID:DataONEorg,项目名称:annotator,代码行数:32,代码来源:JsonAnnotatorStore.java

示例5: allFilter

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public static <T> Collection<T> allFilter(Collection<T> collection, Predicate... predicates) {
        if (collection == null || collection.isEmpty() || predicates == null) {
            return collection;
        } else {
//          Collection<T> list = new ArrayList<T>();
//          list.addAll(collection);
            Collection<T> list = new ArrayList<>(collection);
            Predicate predicate = PredicateUtils.allPredicate(predicates);
            CollectionUtils.filter(list, predicate);
            return list;
        }
    }
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:13,代码来源:ColUtils.java

示例6: anyFilter

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public static <T> Collection<T> anyFilter(Collection<T> collection, Predicate... predicates) {
        if (collection == null || collection.isEmpty() || predicates == null) {
            return collection;
        } else {
//          Collection<T> list = new ArrayList<T>();
//          list.addAll(collection);
            Collection<T> list = new ArrayList<>(collection);
            Predicate predicate = PredicateUtils.anyPredicate(predicates);
            CollectionUtils.filter(list, predicate);
            return list;
        }
    }
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:13,代码来源:ColUtils.java

示例7: oneFilter

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public static <T> Collection<T> oneFilter(Collection<T> collection, Predicate... predicates) {
        if (collection == null || collection.isEmpty() || predicates == null) {
            return collection;
        } else {
//          Collection<T> list = new ArrayList<T>();
//          list.addAll(collection);
            Collection<T> list = new ArrayList<>(collection);
            Predicate predicate = PredicateUtils.onePredicate(predicates);
            CollectionUtils.filter(list, predicate);
            return list;
        }
    }
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:13,代码来源:ColUtils.java

示例8: noneFilter

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public static <T> Collection<T> noneFilter(Collection<T> collection, Predicate... predicates) {
        if (collection == null || collection.isEmpty() || predicates == null) {
            return collection;
        } else {
//          Collection<T> list = new ArrayList<T>();
//          list.addAll(collection);
            Collection<T> list = new ArrayList<>(collection);
            Predicate predicate = PredicateUtils.nonePredicate(predicates);
            CollectionUtils.filter(list, predicate);
            return list;
        }
    }
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:13,代码来源:ColUtils.java

示例9: getPredicateFromSearchFilter

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) {
    List<Predicate> predicates = new ArrayList<>();

    final String type         = searchFilter.getParam(SearchFilter.PARAM_TYPE);
    final String name         = searchFilter.getParam(SearchFilter.PARAM_NAME);
    final String supertype    = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE);
    final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE);

    // Add filter for the type/category
    if (StringUtils.isNotBlank(type)) {
        predicates.add(getTypePredicate(type));
    }

    // Add filter for the name
    if (StringUtils.isNotBlank(name)) {
        predicates.add(getNamePredicate(name));
    }

    // Add filter for the supertype
    if (StringUtils.isNotBlank(supertype)) {
        predicates.add(getSuperTypePredicate(supertype));
    }

    // Add filter for the supertype negation
    if (StringUtils.isNotBlank(notSupertype)) {
        predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype)));
    }

    return PredicateUtils.allPredicate(predicates);
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:31,代码来源:FilterUtil.java

示例10: evaluate

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public boolean evaluate(Object arg0) {
	Predicate judgement = new NullPredicate();
	if (predicates.size() == 1) {
		judgement = predicates.get(0);
	} else {
		if (conj == Conjunction.AND) {
			judgement = PredicateUtils.allPredicate(predicates);
		}
		else if (conj == Conjunction.OR) {
			judgement = PredicateUtils.anyPredicate(predicates);
		}
	}
	
	return judgement.evaluate(arg0);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:BaseRule.java

示例11: filterExtensions

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
private static void filterExtensions(DescriptorExtensionList<GhprcExtension, GhprcExtensionDescriptor> descriptors, Class<? extends GhprcExtensionType>... types) {
    List<Predicate> predicates = new ArrayList<Predicate>(types.length);
    for (Class<? extends GhprcExtensionType> type : types) {
        predicates.add(InstanceofPredicate.getInstance(type));

    }
    Predicate anyPredicate = PredicateUtils.anyPredicate(predicates);
    for (GhprcExtensionDescriptor descriptor : descriptors) {
        if (!anyPredicate.evaluate(descriptor)) {
            descriptors.remove(descriptor);
        }
    }
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:14,代码来源:GhprcExtensionDescriptor.java

示例12: MemberFilter

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
private MemberFilter(Predicate memberPredicate) {
    this.memberPredicate = memberPredicate == null ? PredicateUtils.truePredicate() : memberPredicate;
}
 
开发者ID:motech,项目名称:motech,代码行数:4,代码来源:MemberUtil.java

示例13: TaskFlowState

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
public TaskFlowState() {
	tasks = PredicatedList.decorate(Lists.newArrayList(), PredicateUtils.notNullPredicate());
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:4,代码来源:TaskFlowState.java

示例14: not

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
/**
 * 
 * @param predicate
 * @return 
 */
public static Predicate not(Predicate predicate){
	Assert.notNull(predicate);
	
	return PredicateUtils.notPredicate(predicate);
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:11,代码来源:PredicateFactory.java

示例15: and

import org.apache.commons.collections.PredicateUtils; //导入依赖的package包/类
/**
 * 
 * @param predicates
 * @return 
 */
public static Predicate and(Predicate... predicates){
	Assert.notNull(predicates);
	
	return PredicateUtils.allPredicate(predicates);
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:11,代码来源:PredicateFactory.java


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