List of usage examples for org.apache.commons.collections PredicateUtils allPredicate
public static Predicate allPredicate(Collection predicates)
From source file:org.apache.ranger.biz.KmsKeyMgr.java
private Predicate getPredicate(KeySearchFilter filter) { if (filter == null || filter.isEmpty()) { return null; }/*from w ww . ja v a 2 s . co m*/ List<Predicate> predicates = new ArrayList<Predicate>(); addPredicateForKeyName(filter.getParam(KeySearchFilter.KEY_NAME), predicates); Predicate ret = CollectionUtils.isEmpty(predicates) ? null : PredicateUtils.allPredicate(predicates); return ret; }
From source file:org.apache.ranger.plugin.store.AbstractPredicateUtil.java
public Predicate getPredicate(SearchFilter filter) { if (filter == null || filter.isEmpty()) { return null; }//from ww w . ja va2s . c o m List<Predicate> predicates = new ArrayList<Predicate>(); addPredicates(filter, predicates); Predicate ret = CollectionUtils.isEmpty(predicates) ? null : PredicateUtils.allPredicate(predicates); return ret; }
From source file:org.fl.modules.excel.jxl.JxlImportExcelRule.java
@Override public ExcelReturn validateExcelData() { Sheet sheet = workbook.getSheet(0);//from ww w. ja v a 2s .c o m ExcelReturn excelReturn = new ExcelReturn(); try { boolean isSame = false; for (int row = 2; row < sheet.getRows(); row++) { Cell[] cells = sheet.getRow(row); columns = cells.length; List<ImportValidateRule> list = createImportValidateRules(createRowCellValue(cells)); ImportValidatePredicate firstNameEqlPredicate = new ImportValidatePredicate(); Predicate[] allPredicateArray = { firstNameEqlPredicate }; Predicate allPredicate = PredicateUtils.allPredicate(allPredicateArray); Collection<ImportValidateRule> filteredSuccessCollection = CollectionUtils.select(list, allPredicate); Collection<ImportValidateRule> filteredCollection = CollectionUtils.selectRejected(list, allPredicate); // excelReturn.getRightCollection().add(list); } } catch (Exception e) { e.printStackTrace(); } finally { workbook.close(); } return excelReturn; }
From source file:org.fl.modules.test.excel.PredicateChainExample.java
/** * Here we are adding multiple predicate * filters the collection so that final person object will contain * firstName as "ganesh" & lastName as "gowtham" */// www. ja va2 s .c o m void filterDataUsingMultipleCriteria() { // ImportValidateRule importValidateRule = new ImportValidateRule(); // importValidateRule.setAlias("?"); // importValidateRule.setIndex(0); // importValidateRule.setRule(Rule.emptyOrNull); ImportValidatePredicate firstNameEqlPredicate = new ImportValidatePredicate(); // firstNameEqlPredicate.setImportValidateRule(importValidateRule); Predicate[] allPredicateArray = { firstNameEqlPredicate }; Predicate allPredicate = PredicateUtils.allPredicate(allPredicateArray); Collection<ImportValidateRule> filteredSuccessCollection = CollectionUtils.select(personList, allPredicate); Collection<ImportValidateRule> filteredCollection = CollectionUtils.selectRejected(personList, allPredicate); // CollectionUtils.filter(personList, firstNameEqlPredicate); // for (ImportValidateRule person : personList) { // System.out.println(person.toString()); // } }
From source file:org.sakaiproject.conditions.impl.BaseRule.java
public boolean evaluate(Object arg0) { Predicate judgement = new NullPredicate(); if (predicates.size() == 1) { judgement = predicates.get(0);//from ww w. j ava 2 s . co m } else { if (conj == Conjunction.AND) { judgement = PredicateUtils.allPredicate(predicates); } else if (conj == Conjunction.OR) { judgement = PredicateUtils.anyPredicate(predicates); } } return judgement.evaluate(arg0); }