List of usage examples for com.google.common.base Predicates in
public static <T> Predicate<T> in(Collection<? extends T> target)
From source file:org.apache.aurora.scheduler.filter.AttributeFilter.java
/** * Tests whether a constraint is satisfied by attributes. * * @param values Host attribute values./*from ww w .j a v a 2 s . c o m*/ * @param constraint Constraint to match. * @return {@code true} if the attribute satisfies the constraint, {@code false} otherwise. */ static boolean matches(Set<String> values, IValueConstraint constraint) { boolean match = Iterables.any(constraint.getValues(), Predicates.in(values)); return constraint.isNegated() ^ match; }
From source file:com.google.devtools.build.android.ziputils.SplitZipFilters.java
/** * Returns a predicate that returns true for filenames contained in the given zip file. *///from w ww . jav a 2s. c o m public static Predicate<String> entriesIn(String filterZip) throws IOException { // Aggregate filenames into a set so Predicates.in is efficient ImmutableSet.Builder<String> filenames = ImmutableSet.builder(); @SuppressWarnings("resource") // ZipIn takes ownership but isn't Closable ZipIn zip = new ZipIn(new FileInputStream(filterZip).getChannel(), filterZip); for (DirectoryEntry entry : zip.centralDirectory().list()) { filenames.add(entry.getFilename()); } return Predicates.in(filenames.build()); }
From source file:org.apache.abdera2.common.selector.Selectors.java
public static <X> Selector<X> oneOf(final X... items) { return forPredicate(Predicates.in(ImmutableSet.<X>copyOf(items))); }
From source file:pkmntv.logic.TypeEffect.java
public static Map getWeakEffectMap() { return Maps.filterValues(TYPE_MAP, Predicates.in(WEAK_FACTORS)); }
From source file:zotmc.collect.FluentPredicate.java
public static <T> FluentPredicate<T> in(Collection<? extends T> target) { return from(Predicates.in(target)); }
From source file:co.cask.cdap.common.lang.FilterClassLoader.java
public static FilterClassLoader create(ProgramType programType, ClassLoader parentClassLoader) { Set<String> visibleResources = ProgramResources.getVisibleResources(programType); ImmutableSet.Builder<String> visiblePackages = ImmutableSet.builder(); for (String resource : visibleResources) { if (resource.endsWith(".class")) { int idx = resource.lastIndexOf('/'); // Ignore empty package if (idx > 0) { visiblePackages.add(resource.substring(0, idx)); }/* www . j av a 2s . c o m*/ } } return new FilterClassLoader(Predicates.in(visibleResources), Predicates.in(visiblePackages.build()), parentClassLoader); }
From source file:brooklyn.event.feed.http.HttpValueFunctions.java
public static Function<HttpToolResponse, Boolean> responseCodeEquals(final int... expected) { List<Integer> expectedList = Lists.newArrayList(); for (int e : expected) { expectedList.add((Integer) e); }/*w w w. j a va2 s .c o m*/ return Functionals.chain(HttpValueFunctions.responseCode(), Functions.forPredicate(Predicates.in(expectedList))); }
From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java
/** * Tests whether a constraint is satisfied by attributes. * * @param attributes Host attributes.//from w w w.j a va 2 s . co m * @param constraint Constraint to match. * @return {@code true} if the attribute satisfies the constraint, {@code false} otherwise. */ static boolean matches(Set<Attribute> attributes, IValueConstraint constraint) { Set<String> allAttributes = ImmutableSet .copyOf(Iterables.concat(Iterables.transform(attributes, GET_VALUES))); boolean match = Iterables.any(constraint.getValues(), Predicates.in(allAttributes)); return constraint.isNegated() ^ match; }
From source file:com.google.devtools.build.lib.skyframe.BuildTargetPatternsResultBuilder.java
@Override void addLabelsOfNegativePattern(ResolvedTargets<Label> labels) { resolvedLabelsBuilder.filter(Predicates.not(Predicates.in(labels.getTargets()))); }
From source file:org.jclouds.rest.functions.ReturnAbsentOn403Or404Or500.java
public Object apply(Exception from) { Boolean returnVal = returnValueOnCodeOrNull(from, true, Predicates.in(Ints.asList(403, 404, 500))); if (returnVal != null) return Optional.absent(); throw Throwables.propagate(from); }