本文整理了Java中org.apache.commons.collections.CollectionUtils.select()
方法的一些代码示例,展示了CollectionUtils.select()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.select()
方法的具体详情如下:
包路径:org.apache.commons.collections.CollectionUtils
类名称:CollectionUtils
方法名:select
[英]Selects all elements from input collection which match the given predicate into an output collection.
A null
predicate matches no elements.
[中]将输入集合中与给定谓词匹配的所有元素选择到输出集合中。null
谓词不匹配任何元素。
代码示例来源:origin: commons-collections/commons-collections
/**
* 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;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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;
}
代码示例来源:origin: wildfly/wildfly
/**
* 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;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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);
}
});
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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());
}
});
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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());
}
});
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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());
}
});
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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;
}
});
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* 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;
}
});
}
代码示例来源:origin: commons-collections/commons-collections
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());
}
代码示例来源:origin: mulesoft/mule
private <T extends DeployableArtifact> Collection getArtifactsToRedeploy(Collection<T> collection) {
return select(collection, object -> ((DeployableArtifact) object).getDescriptor().isRedeploymentEnabled());
}
代码示例来源:origin: org.mule.runtime/mule-core
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();
}
}
代码示例来源:origin: FenixEdu/fenixedu-academic
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();
}
});
}
代码示例来源:origin: FenixEdu/fenixedu-academic
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);
}
});
}
代码示例来源:origin: FenixEdu/fenixedu-academic
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;
}
代码示例来源:origin: com.atlassian.jira/jira-core
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());
}
});
}
代码示例来源:origin: FenixEdu/fenixedu-academic
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;
}
代码示例来源:origin: com.atlassian.jira/jira-core
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;
}
}
代码示例来源:origin: com.carbonfive.db-support/db-migration
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;
}
代码示例来源:origin: com.atlassian.jira/jira-core
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;
}
内容来源于网络,如有侵权,请联系作者删除!