/** * Selects all elements from input collection which match the given predicate * into an output collection. * <p> * A <code>null</code> predicate matches no elements. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection select(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); select(inputCollection, predicate, answer); return answer; }
/** * Delegates to {@link CollectionUtils#select(Collection, org.apache.commons.collections.Predicate)}, but will * force the return type to be a List<T>. * * @param inputCollection * @param predicate * @return */ public static <T> List<T> selectList(Collection<T> inputCollection, TypedPredicate<T> predicate) { ArrayList<T> answer = new ArrayList<T>(inputCollection.size()); CollectionUtils.select(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from input collection which match the given predicate * into an output collection. * <p> * A <code>null</code> predicate matches no elements. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection select(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); select(inputCollection, predicate, answer); return answer; }
/** * Grabs a filtered list of actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveActions(final boolean listGridIsReadOnly) { return (List<ListGridAction>) CollectionUtils.select(getListGridActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(listGridIsReadOnly); } }); }
/** * Grabs a filtered list of toolbar actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveToolbarActions() { return (List<ListGridAction>) CollectionUtils.select(getToolbarActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(getIsReadOnly()); } }); }
/** * Grabs a filtered list of row actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveRowActions() { return (List<ListGridAction>) CollectionUtils.select(getRowActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(getIsReadOnly()); } }); }
/** * Grabs a filtered list of row actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveModalRowActions() { return (List<ListGridAction>) CollectionUtils.select(getModalRowActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(getIsReadOnly()); } }); }
/** * Grabs a filtered list of row action groupss filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveRowActionGroups() { return (List<ListGridAction>) CollectionUtils.select(getRowActionGroups(), new TypedPredicate<ListGridActionGroup>() { @Override public boolean eval(ListGridActionGroup actionGroup) { boolean result = false; for (ListGridAction action : actionGroup.getListGridActions()) { if (action.getForListGridReadOnly().equals(getIsReadOnly())) { result = true; } } return result; } }); }
/** * Grabs a filtered list of toolbar action groupss filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveToolbarActionGroups() { return (List<ListGridAction>) CollectionUtils.select(getToolbarActionGroups(), new TypedPredicate<ListGridActionGroup>() { @Override public boolean eval(ListGridActionGroup actionGroup) { boolean result = false; for (ListGridAction action : actionGroup.getListGridActions()) { if (action.getForListGridReadOnly().equals(getIsReadOnly())) { result = true; } } return result; } }); }
public void testSelect() { List list = new ArrayList(); list.add("One"); list.add("Two"); list.add("Three"); list.add("Four"); Collection output = CollectionUtils.select(list, EQUALS_TWO); assertEquals(4, list.size()); assertEquals(1, output.size()); assertEquals("Two", output.iterator().next()); }
private <T extends DeployableArtifact> Collection getArtifactsToRedeploy(Collection<T> collection) { return select(collection, object -> ((DeployableArtifact) object).getDescriptor().isRedeploymentEnabled()); }
public Collection<?> select(Predicate predicate) { Lock readLock = registryLock.readLock(); try { readLock.lock(); return org.apache.commons.collections.CollectionUtils.select(registry.values(), predicate); } finally { readLock.unlock(); } }
public List<Professorship> getDegreeProfessorshipsByExecutionPeriod(final ExecutionSemester executionSemester) { return (List<Professorship>) CollectionUtils.select(getProfessorships(), new Predicate() { @Override public boolean evaluate(Object arg0) { Professorship professorship = (Professorship) arg0; return professorship.getExecutionCourse().getExecutionPeriod() == executionSemester && !professorship.getExecutionCourse().isMasterDegreeDFAOrDEAOnly(); } }); }
public List<Branch> getCommonAreas() { return (List<Branch>) CollectionUtils.select(getAreasSet(), new Predicate() { @Override public boolean evaluate(Object obj) { Branch branch = (Branch) obj; if (branch.getBranchType() == null) { return branch.getName().equals("") && branch.getCode().equals(""); } return branch.getBranchType().equals(org.fenixedu.academic.domain.branch.BranchType.COMNBR); } }); }
protected List<ApprovedLearningAgreementExecutedAction> getSentLearningAgreementActions() { List<ApprovedLearningAgreementExecutedAction> executedActionList = new ArrayList<ApprovedLearningAgreementExecutedAction>(); CollectionUtils.select(getExecutedActionsSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { return ((ApprovedLearningAgreementExecutedAction) arg0).isSentLearningAgreementAction(); }; }, executedActionList); Collections.sort(executedActionList, Collections.reverseOrder(ExecutedAction.WHEN_OCCURED_COMPARATOR)); return executedActionList; }
public Collection getAllProjects() { return CollectionUtils.select(super.getAllProjects(), new Predicate() { public boolean evaluate(Object object) { ProjectOption projectOption = (ProjectOption) object; return !getProjectId().toString().equals(projectOption.getId()); } }); }
public static List<EventReportQueueJob> retrieveAllGeneratedReports() { List<EventReportQueueJob> reports = new ArrayList<>(); CollectionUtils.select(Bennu.getInstance().getQueueJobSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { return arg0 instanceof EventReportQueueJob; } }, reports); return reports; }
public FieldConfigScheme getExistingAutoCreatedScheme() { Collection c = CollectionUtils.select(issueTypeSchemeManager.getAllSchemes(), new FieldConfigPredicate(null, getDefaultNameForNewScheme())); if (c != null && !c.isEmpty()) { return (FieldConfigScheme) c.iterator().next(); } else { return null; } }
public SortedSet<Migration> pendingMigrations() { Set<String> appliedMigrations = determineAppliedMigrationVersions(); Set<Migration> availableMigrations = migrationResolver.resolve(); SortedSet<Migration> pendingMigrations = new TreeSet<Migration>(); CollectionUtils.select(availableMigrations, new PendingMigrationPredicate(appliedMigrations), pendingMigrations); return pendingMigrations; }
private Collection<Option> getOptionsForConfig(FieldConfig fieldConfig, IssueContext issue, Map displayParameters, IssueTypeKind issueTypeKind, Collection<String> issueTypeSkip) { Collection<Option> options = optionSetManager.getOptionsForConfig(fieldConfig).getOptions(); options = CollectionUtils.select(options, new ValidIssueTypePredicate(issue, displayParameters, issueTypeKind, issueTypeSkip)); return options; }