本文整理汇总了Java中org.apache.commons.collections.PredicateUtils.allPredicate方法的典型用法代码示例。如果您正苦于以下问题:Java PredicateUtils.allPredicate方法的具体用法?Java PredicateUtils.allPredicate怎么用?Java PredicateUtils.allPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections.PredicateUtils
的用法示例。
在下文中一共展示了PredicateUtils.allPredicate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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();
}
示例3: 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;
}
}
示例4: 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);
}
示例5: 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);
}
示例6: and
import org.apache.commons.collections.PredicateUtils; //导入方法依赖的package包/类
/**
*
* @param predicates
* @return
*/
public static Predicate and(Predicate... predicates){
Assert.notNull(predicates);
return PredicateUtils.allPredicate(predicates);
}