Example usage for org.apache.commons.collections CollectionUtils filter

List of usage examples for org.apache.commons.collections CollectionUtils filter

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils filter.

Prototype

public static void filter(Collection collection, Predicate predicate) 

Source Link

Document

Filter the collection by applying a Predicate to each element.

Usage

From source file:com.dotosoft.dotoquiz.tools.thirdparty.PicasawebClient.java

public List filterPhoto(List photoCollection, String filterExpression, Object filterValue) throws Exception {
    BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate(filterExpression,
            filterValue);/*  w  ww  .  j  av a2  s .com*/
    CollectionUtils.filter(photoCollection, predicate);
    return photoCollection;
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java

/**
 * Checks if one of the String... array elements exists in the idTypes list.
 *
 * @param idTypes/*  www . j  a  v a2  s.  c  o  m*/
 * @param values
 * @return
 */
public boolean schemeIdContainsAny(List<IdType> idTypes, String... values) {
    if (values == null || values.length == 0 || CollectionUtils.isEmpty(idTypes)) {
        return true;
    }

    idTypes = new ArrayList<>(idTypes);
    CollectionUtils.filter(idTypes, PredicateUtils.notNullPredicate());

    for (String val : values) {
        for (IdType IdType : idTypes) {
            if (val.equals(IdType.getSchemeId())) {
                return false;
            }
        }
    }
    return true;
}

From source file:adalid.core.Display.java

public List<? extends DisplayField> getRootMasterHeadingFields() {
    List<? extends DisplayField> fields = new ArrayList<>(getMasterHeadingFields());
    CollectionUtils.filter(fields, new IsDisplayRootField());
    Collections.sort(fields, byPropertySequenceNumber);
    return fields;
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultCompanyB2BCommerceFacade.java

protected B2BSelectionData populateRolesForCustomer(final B2BCustomerModel customerModel,
        final B2BSelectionData b2BSelectionData) {
    final List<String> roles = new ArrayList<String>();
    final Set<PrincipalGroupModel> roleModels = new HashSet<PrincipalGroupModel>(customerModel.getGroups());
    CollectionUtils.filter(roleModels,
            PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUnitModel.class)));
    CollectionUtils.filter(roleModels,//from   w  w  w.  j av  a  2 s  . co  m
            PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUserGroupModel.class)));

    for (final PrincipalGroupModel role : roleModels) {
        roles.add(role.getUid());
    }
    b2BSelectionData.setRoles(roles);

    return b2BSelectionData;
}

From source file:adalid.core.Display.java

public List<? extends DisplayField> getJoinFields() {
    List<? extends DisplayField> fields = new ArrayList<>(getFields());
    CollectionUtils.filter(fields, new IsDisplayJoinField());
    return fields;
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java

public boolean isAllSchemeIdsPresent(List<IdType> idTypes) {
    if (CollectionUtils.isEmpty(idTypes)) {
        return false;
    }//from w  ww.  ja  va 2 s  . co  m

    idTypes = new ArrayList<>(idTypes);
    CollectionUtils.filter(idTypes, PredicateUtils.notNullPredicate());

    for (IdType idType : idTypes) {
        if (!isSchemeIdPresent(idType)) {
            return true;
        }
    }

    return false;
}

From source file:com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager.java

public List<String> getAllRealtimeTables() {
    List<String> ret = _helixAdmin.getResourcesInCluster(_helixClusterName);
    CollectionUtils.filter(ret, new Predicate() {
        @Override/*from w ww . j  av a  2 s .com*/
        public boolean evaluate(Object object) {
            if (object == null) {
                return false;
            }
            if (object.toString().endsWith("_" + ServerType.REALTIME.toString())) {
                return true;
            }
            return false;
        }
    });
    return ret;
}

From source file:io.neba.core.resourcemodels.registration.ModelRegistry.java

/**
 * Removes all resource models originating from the given bundle from this registry.
 *
 * @param bundle must not be <code>null</code>.
 *//*  ww w  .  j a  v  a  2  s . c  o  m*/
void removeResourceModels(final Bundle bundle) {
    this.logger.info("Removing resource models of bundle " + displayNameOf(bundle) + "...");
    MatchedBundlesPredicate sourcesWithBundles = new MatchedBundlesPredicate(bundle);
    for (Collection<OsgiModelSource<?>> values : this.typeNameToModelSourcesMap.values()) {
        CollectionUtils.filter(values, sourcesWithBundles);
    }
    clearLookupCaches();
    this.logger.info("Removed " + sourcesWithBundles.getFilteredElements() + " resource models of bundle "
            + displayNameOf(bundle) + "...");
}

From source file:models.NotificationEvent.java

private static void filterReceivers(final NotificationEvent event) {
    final Project project = event.getProject();
    if (project == null) {
        return;/*from ww  w .  jav  a  2s .co  m*/
    }

    final Resource resource = project.asResource();
    CollectionUtils.filter(event.receivers, new Predicate() {
        @Override
        public boolean evaluate(Object obj) {
            User receiver = (User) obj;
            if (receiver.loginId == null) {
                return false;
            }

            if (!Watch.isWatching(receiver, resource)) {
                return true;
            }
            return UserProjectNotification.isEnabledNotiType(receiver, project, event.eventType);
        }
    });
}

From source file:hr.fer.zemris.vhdllab.platform.manager.workspace.DefaultWorkspaceManager.java

@Override
public List<Project> getProjects(Predicate filter, Transformer transformer) {
    List<Project> projects = new ArrayList<Project>(getProjects());
    CollectionUtils.filter(projects, filter);
    CollectionUtils.transform(projects, transformer);
    return projects;
}