List of usage examples for com.google.common.collect Collections2 filter
@CheckReturnValue public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate)
From source file:org.opensaml.xmlsec.impl.WhitelistPredicate.java
/** * Constructor.//from ww w . j a v a2 s .c om * * @param algorithms collection of whitelisted algorithms */ public WhitelistPredicate(@Nonnull Collection<String> algorithms) { Constraint.isNotNull(algorithms, "Whitelist may not be null"); whitelist = new HashSet<>(Collections2.filter(algorithms, Predicates.notNull())); }
From source file:greenapi.core.model.resources.RamMemoryStat.java
@Override public Collection<IOStatProperty> properties() { return Collections2.filter(super.properties(), new Predicate<IOStatProperty>() { public boolean apply(IOStatProperty property) { return property.stat().device().startsWith("dm"); }// ww w. jav a 2 s. c o m }); }
From source file:org.eclipse.emf.compare.diff.internal.merge.impl.ReferenceOrderChangeMerger.java
/** * {@inheritDoc}/*from w w w . j a va2s . c om*/ * * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doApplyInOrigin() */ @Override public void doApplyInOrigin() { final ReferenceOrderChange theDiff = (ReferenceOrderChange) this.diff; final EObject leftElement = theDiff.getLeftElement(); final Collection<EObject> target = Lists .newArrayList(Collections2.filter(theDiff.getLeftTarget(), new Predicate<EObject>() { public boolean apply(EObject input) { return !input.eIsProxy() || !DefaultMerger.isEMFCompareProxy(((InternalEObject) input).eProxyURI()); } })); try { EFactory.eSet(leftElement, theDiff.getReference().getName(), target); } catch (final FactoryException e) { EMFComparePlugin.log(e, true); } }
From source file:com.anathema_roguelike.characters.abilities.targetingstrategies.targetmodes.PointsMode.java
@Override public Collection<Character> getTargets(Shape shape, Character character, Predicate<Character> targetValidator) { HashSet<Character> ret = new HashSet<>(); Environment level = character.getEnvironment(); for (Point point : shape.getPoints()) { ret.addAll(Collections2.filter(level.getEntitiesAt(point, Character.class), targetValidator)); }/*from w w w . j a v a 2 s . c om*/ return ret; }
From source file:com.ngdata.sep.tools.monitoring.ReplicationStatus.java
public Collection<String> getPeers() { return Collections2.filter(statusByPeerAndServer.keySet(), Predicates.not(RECOVERED_QUEUE_PREDICATE)); }
From source file:com.googlecode.t7mp.CheckT7ArtifactsStep.java
@SuppressWarnings("unchecked") @Override// www . j a v a 2 s . c o m public void execute(Context context) { mojo = ((MavenPluginContext) context).getMojo(); configuration = context.getConfiguration(); log = context.getLog(); noVersionPredicate = new NoVersionPredicate(log); log.debug("Fitler libs"); noVersionArtifacts.addAll(Collections2.filter(configuration.getWebapps(), noVersionPredicate)); log.debug("Filter webapps"); noVersionArtifacts.addAll(Collections2.filter(configuration.getLibs(), noVersionPredicate)); if (noVersionArtifacts.size() > 0) { log.debug("artifacts without version found "); List<Dependency> projectDependencies = mojo.getMavenProject().getDependencies(); List<Dependency> managedDependencies = mojo.getMavenProject().getDependencyManagement() .getDependencies(); if (log.isDebugEnabled()) { log.debug("Project-Dependencies : " + projectDependencies.size()); logDependencies(projectDependencies); log.debug("Managed-Dependencies : " + managedDependencies.size()); logDependencies(managedDependencies); } Predicate<Dependency> depsfilter = new FindVersionPredicate(noVersionArtifacts, log); log.debug("Filter projectArtifacts"); // first managed dependencies Collection<Dependency> depsApplied = Collections2.filter(managedDependencies, depsfilter); // project dependencies can overwrite filtering results depsApplied.addAll(Collections2.filter(projectDependencies, depsfilter)); log.debug(depsApplied.size() + " dependenciey applied"); log.debug("check for noversion-artifacts again ..."); Collection<AbstractArtifact> noVersionsFound = Collections2.filter(noVersionArtifacts, noVersionPredicate); if (noVersionsFound.size() > 0) { for (AbstractArtifact artifact : noVersionsFound) { log.error("No version configured for artifact --" + artifact.toString()); } throw new TomcatSetupException("ConfigurationException"); } } }
From source file:org.eclipse.viatra.query.runtime.localsearch.operations.extend.nobase.IterateOverEClassInstances.java
public IterateOverEClassInstances(int position, EClass clazz, Collection<EObject> allModelContents) { super(position); this.clazz = clazz; contents = Collections2.filter(allModelContents, new Predicate<EObject>() { @Override/*from www . ja v a2 s. c o m*/ public boolean apply(EObject input) { return IterateOverEClassInstances.this.clazz.isSuperTypeOf(input.eClass()); } }); }
From source file:org.calrissian.accumulorecipes.eventstore.support.query.validators.AndSingleDepthOnlyValidator.java
@Override public void begin(ParentNode node) { if (!(node instanceof AndNode)) throw new IllegalArgumentException("Not an And Node"); int size = node.getNodes().size(); if (node.getNodes() == null || size < 2) throw new IllegalArgumentException("At least 2 query leaves expected"); if (!NodeUtils.parentContainsOnlyLeaves(node)) throw new IllegalArgumentException("Only Leaf nodes expected. Not a single depth node"); //make sure not all are NotEqual nodes Collection<Node> notEqNodes = Collections2.filter(node.getNodes(), new Predicate<Node>() { @Override// w ww.j av a2 s . co m public boolean apply(Node node) { return node instanceof NotEqualsLeaf; } }); if (notEqNodes != null && notEqNodes.size() == size) { throw new IllegalArgumentException("Not every leaf can be a not equals"); } }
From source file:com.anathema_roguelike.characters.abilities.AbilitySet.java
public <T extends Ability> Collection<T> get(final Class<T> superclass, Predicate<T> predicate) { return Collections2.filter(get(superclass), predicate); }
From source file:com.complexible.common.util.ClassPath.java
/** * Return all the classes which implement/extend the given class and are instantiable (ie not abstract, * not interfaces themselves)// ww w .j a v a2 s. co m * @param theClass the parent class/interface * @return all matching classes */ public static Collection<Class> instantiableClasses(Class<?> theClass) { return Collections2.filter(classes(theClass), new Predicate<Class>() { public boolean apply(final Class theClass) { return !theClass.isInterface() && !Modifier.isAbstract(theClass.getModifiers()); } }); }