List of usage examples for org.apache.commons.collections4 ListUtils select
public static <E> List<E> select(final Collection<? extends E> inputCollection, final Predicate<? super E> predicate)
From source file:it.infn.ct.futuregateway.apiserver.resources.Task.java
/** * Retrieves the associated infrastructure Id. * This is the Id of the infrastructure selected to execute the task among * the many the application can run on.//from ww w. j a v a2 s.com * * @return The infrastructure Id */ public String getAssociatedInfrastructureId() { if ((associatedInfrastructureId == null || associatedInfrastructureId.isEmpty()) && applicationDetail != null) { List<Infrastructure> infras = ListUtils.select(applicationDetail.getInfrastructures(), new Predicate<Infrastructure>() { @Override public boolean evaluate(final Infrastructure t) { return t.isEnabled(); } }); Random rand = new Random((new Date()).getTime()); while (!infras.isEmpty()) { Infrastructure i = infras.remove(rand.nextInt(infras.size())); if (i.isEnabled()) { setAssociatedInfrastructureId(i.getId()); return associatedInfrastructureId; } } } return associatedInfrastructureId; }
From source file:org.kuali.coeus.common.impl.unit.UnitServiceImpl.java
protected List<Unit> findUnitsWithDirectParent(List<Unit> units, final String directParent) { if (CollectionUtils.isNotEmpty(units)) { final List<Unit> matched = ListUtils.select(units, new Predicate<Unit>() { @Override//from w ww. j av a2 s. com public boolean evaluate(Unit input) { return input.getParentUnitNumber() != null && input.getParentUnitNumber().equals(directParent); } }); final List<Unit> totalMatched = new ArrayList<>(matched); for (Unit child : matched) { totalMatched.addAll(findUnitsWithDirectParent(units, child.getUnitNumber())); } return totalMatched; } return Collections.emptyList(); }
From source file:org.kuali.kra.timeandmoney.service.impl.TimeAndMoneyHistoryServiceImpl.java
protected List<TransactionDetail> getIntermediateTransactions(List<TransactionDetail> transactions) { return ListUtils.select(transactions, new Predicate<TransactionDetail>() { @Override//from www. ja va 2 s. c o m public boolean evaluate(TransactionDetail detail) { return TransactionDetailType.INTERMEDIATE.toString().equals(detail.getTransactionDetailType()); } }); }