List of usage examples for com.google.common.base Predicates compose
public static <A, B> Predicate<A> compose(Predicate<B> predicate, Function<A, ? extends B> function)
From source file:com.complexible.common.openrdf.model.Statements.java
public static Predicate<Statement> objectIs(final Class<? extends Value> theValue) { return Predicates.compose(Predicates.instanceOf(theValue), object()); }
From source file:com.android.builder.files.IncrementalRelativeFileSets.java
/** * Reads a directory and adds all files in the directory in a new incremental relative set. * The status of each file is set to {@link FileStatus#NEW}. This method is used to construct * an initial set of files and is, therefore, an incremental update from zero. * * @param directory the directory, must be an existing directory * @return the file set/* ww w . j av a 2 s. c o m*/ */ @NonNull public static ImmutableMap<RelativeFile, FileStatus> fromDirectory(@NonNull File directory) { Preconditions.checkArgument(directory.isDirectory(), "!directory.isDirectory()"); Set<RelativeFile> files = RelativeFiles.fromDirectory(directory); files = Sets.filter(files, Predicates.compose(Files.isFile(), RelativeFile.EXTRACT_FILE)); Map<RelativeFile, FileStatus> map = Maps.asMap(files, Functions.constant(FileStatus.NEW)); return ImmutableMap.copyOf(map); }
From source file:zotmc.collect.delegate.IterativeMap.java
protected Predicate<Entry<K, V>> keyEqualTo(K key) { return Predicates.compose(equalTo(key), Conversions.<K, V>entryToKey()); }
From source file:tile80.world80.World80HOF.java
@Override public Tile80 getTileByPos(Pair pos) { return FluentIterable.from(world).filter(Predicates.compose(Predicates.equalTo(pos), onlyCoord)).first() .or(Tile80.nothing); }
From source file:zotmc.collect.delegate.IterativeMap.java
protected Predicate<Entry<K, V>> valueEqualTo(V value) { return Predicates.compose(equalTo(value), Conversions.<K, V>entryToValue()); }
From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java
/** * Tests whether an attribute matches a limit constraint. * * @param attributes Attributes to match against. * @param jobKey Key of the job with the limited constraint. * @param limit Limit value./* w ww .j a v a 2 s . c o m*/ * @param activeTasks All active tasks in the system. * @param attributeFetcher Interface for fetching attributes for hosts in the system. * @return {@code true} if the limit constraint is satisfied, {@code false} otherwise. */ static boolean matches(final Set<Attribute> attributes, final IJobKey jobKey, int limit, Iterable<IScheduledTask> activeTasks, final AttributeLoader attributeFetcher) { Predicate<IScheduledTask> sameJob = Predicates.compose(Predicates.equalTo(jobKey), Tasks.SCHEDULED_TO_JOB_KEY); Predicate<IScheduledTask> hasAttribute = new Predicate<IScheduledTask>() { @Override public boolean apply(IScheduledTask task) { Iterable<Attribute> hostAttributes = attributeFetcher.apply(task.getAssignedTask().getSlaveHost()); return Iterables.any(hostAttributes, Predicates.in(attributes)); } }; return limit > Iterables.size(Iterables.filter(activeTasks, Predicates.and(sameJob, hasAttribute))); }
From source file:com.twitter.aurora.scheduler.storage.mem.MemUpdateStore.java
private static Predicate<JobUpdateConfiguration> hasRole(String role) { checkNotNull(role); return Predicates.compose(Predicates.equalTo(role), GET_ROLE); }
From source file:tile80.world80.World80HOF.java
@Override public Tile80 getTileById(String Symbol) { return FluentIterable.from(world).filter(Predicates.compose(Predicates.equalTo(Symbol), onlyId)).first() .or(Tile80.nothing); }
From source file:org.sosy_lab.cpachecker.cpa.predicate.counterexamples.ABEBlockCounterexampleFilter.java
@Override protected Optional<ImmutableList<CFANode>> getCounterexampleRepresentation(CounterexampleInfo counterexample) { return Optional.of(from(counterexample.getTargetPath().asStatesList()) .filter(Predicates.compose(PredicateAbstractState.FILTER_ABSTRACTION_STATES, toState(PredicateAbstractState.class))) .transform(AbstractStates.EXTRACT_LOCATION).toList()); }
From source file:org.richfaces.demo.RF10888.java
private Predicate<Person> contains(String value, Function<Person, CharSequence> accessor) { return Predicates.compose( Predicates.contains(Pattern.compile(Pattern.quote(value), Pattern.CASE_INSENSITIVE)), accessor); }