com.google.common.base.Predicates#compose ( )源码实例Demo

下面列出了com.google.common.base.Predicates#compose ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bazel   文件: RuleClass.java
@VisibleForSerialization
RuleClassNamePredicate(
    ImmutableSet<String> ruleClassNames, PredicateType predicateType, Set<?> overlappable) {
  this.ruleClassNames = ruleClassNames;
  this.predicateType = predicateType;
  this.overlappable = overlappable;

  switch (predicateType) {
    case All_EXCEPT:
      Predicate<String> containing = only(ruleClassNames).asPredicateOfRuleClassName();
      ruleClassNamePredicate =
          new DescribedPredicate<>(
              Predicates.not(containing), "all but " + containing.toString());
      ruleClassPredicate =
          new DescribedPredicate<>(
              Predicates.compose(ruleClassNamePredicate, RuleClass::getName),
              ruleClassNamePredicate.toString());
      break;
    case ONLY:
      ruleClassNamePredicate =
          new DescribedPredicate<>(
              Predicates.in(ruleClassNames), StringUtil.joinEnglishList(ruleClassNames));
      ruleClassPredicate =
          new DescribedPredicate<>(
              Predicates.compose(ruleClassNamePredicate, RuleClass::getName),
              ruleClassNamePredicate.toString());
      break;
    case UNSPECIFIED:
      ruleClassNamePredicate = Predicates.alwaysTrue();
      ruleClassPredicate = Predicates.alwaysTrue();
      break;
    default:
      // This shouldn't happen normally since the constructor is private and within this file.
      throw new IllegalArgumentException(
          "Predicate type was not specified when constructing a RuleClassNamePredicate.");
  }
}
 
源代码2 项目: attic-aurora   文件: ReadOnlySchedulerImpl.java
private Map<IJobKey, IJobConfiguration> getJobs(
    Optional<String> ownerRole,
    Multimap<IJobKey, IScheduledTask> tasks) {

  // We need to synthesize the JobConfiguration from the the current tasks because the
  // ImmediateJobManager doesn't store jobs directly and ImmediateJobManager#getJobs always
  // returns an empty Collection.
  Map<IJobKey, IJobConfiguration> jobs = Maps.newHashMap();

  jobs.putAll(Maps.transformEntries(tasks.asMap(),
      (jobKey, tasks1) -> {

        // Pick the latest transitioned task for each immediate job since the job can be in the
        // middle of an update or some shards have been selectively created.
        TaskConfig mostRecentTaskConfig =
            Tasks.getLatestActiveTask(tasks1).getAssignedTask().getTask().newBuilder();

        return IJobConfiguration.build(new JobConfiguration()
            .setKey(jobKey.newBuilder())
            .setOwner(mostRecentTaskConfig.getOwner())
            .setTaskConfig(mostRecentTaskConfig)
            .setInstanceCount(tasks1.size()));
      }));

  // Get cron jobs directly from the manager. Do this after querying the task store so the real
  // template JobConfiguration for a cron job will overwrite the synthesized one that could have
  // been created above.
  Predicate<IJobConfiguration> configFilter = ownerRole.isPresent()
      ? Predicates.compose(Predicates.equalTo(ownerRole.get()), JobKeys::getRole)
      : Predicates.alwaysTrue();
  jobs.putAll(Maps.uniqueIndex(
      FluentIterable.from(Storage.Util.fetchCronJobs(storage)).filter(configFilter),
      IJobConfiguration::getKey));

  return jobs;
}
 
源代码3 项目: bundletool   文件: TargetingDimensionMatcher.java
/**
 * Returns a convenient predicate on {@link ApkTargeting} message.
 */
public Predicate<ApkTargeting> getApkTargetingPredicate() {
  return Predicates.compose(this::matchesTargeting, this::getTargetingValue);
}
 
源代码4 项目: brooklyn-server   文件: CollectionFunctionals.java
public static Predicate<Iterable<?>> sizeEquals(int targetSize) {
    return Predicates.compose(Predicates.equalTo(targetSize), CollectionFunctionals.sizeFunction());
}
 
源代码5 项目: brooklyn-server   文件: CollectionFunctionals.java
public static <K> Predicate<Map<K,?>> mapSizeEquals(int targetSize) {
    return Predicates.compose(Predicates.equalTo(targetSize), CollectionFunctionals.<K>mapSize());
}
 
源代码6 项目: bazel   文件: ZipEntryPredicates.java
public static Predicate<ZipEntry> classFileFilter(final ImmutableSet<String> classFileNames) {
  return Predicates.compose(classFileNameFilter(classFileNames), zipEntry -> zipEntry.getName());
}
 
源代码7 项目: attic-aurora   文件: StateMachine.java
private static <T> Predicate<Transition<T>> oneSideFilter(
    Function<Transition<T>, T> extractor, final T... states) {
  checkArgument(Iterables.all(Arrays.asList(states), Predicates.notNull()));

  return Predicates.compose(Predicates.in(ImmutableSet.copyOf(states)), extractor);
}
 
源代码8 项目: bundletool   文件: TargetingDimensionMatcher.java
/**
 * Returns a convenient predicate on {@link ModuleTargeting}.
 *
 * <p>As this is used to determine if a conditional module should be installed, the device
 * incompatibility safety checks are not performed. Should this happen, the module will simply
 * fail the matching.
 */
public Predicate<ModuleTargeting> getModuleTargetingPredicate() {
  return Predicates.compose(this::matchesTargeting, this::getTargetingValue);
}