Java Code Examples for com.google.common.collect.FluentIterable#append()

The following examples show how to use com.google.common.collect.FluentIterable#append() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Flavors.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Propagate a build target's flavors in a certain domain to a list of other build targets.
 *
 * @param domain the flavor domain to be propagated.
 * @param buildTarget the build target containing the flavors to be propagated
 * @param deps list of BuildTargetPaths to propagate the flavors to. If a target already contains
 *     one or more flavors in domain, it is left unchanged.
 * @return the list of BuildTargetPaths with any flavors propagated.
 */
public static FluentIterable<BuildTarget> propagateFlavorsInDomainIfNotPresent(
    FlavorDomain<?> domain, BuildTarget buildTarget, FluentIterable<BuildTarget> deps) {
  if (domain.containsAnyOf(buildTarget.getFlavors())) {
    FluentIterable<BuildTarget> targetsWithFlavorsAlready =
        deps.filter(containsFlavors(domain)::test);

    FluentIterable<BuildTarget> targetsWithoutFlavors =
        deps.filter(containsFlavors(domain).negate()::test);

    deps =
        targetsWithFlavorsAlready.append(
            propagateFlavorDomains(buildTarget, ImmutableSet.of(domain), targetsWithoutFlavors));
  }

  return deps;
}
 
Example 2
Source File: AllResourceSelector.java    From raml-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public FluentIterable<Resource> fromApi(Api api) {

    List<Resource> topResources = api.resources();
    FluentIterable<Resource> fi = from(topResources);
    for (Resource resource : topResources) {
        fi = fi.append(fromResource(resource));
    }

    return fi;
}
 
Example 3
Source File: AllResourceSelector.java    From raml-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public FluentIterable<Resource> fromResource(Resource topResource) {
    List<Resource> resources = topResource.resources();
    FluentIterable<Resource> fi = from(resources);
    for (Resource resource : resources) {
        fi = fi.append(fromResource(resource));
    }

    return fi;
}
 
Example 4
Source File: GivenMembersTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@SafeVarargs
private static <T> Set<T> union(Set<T>... sets) {
    FluentIterable<T> result = FluentIterable.of();
    for (Set<T> set : sets) {
        result = result.append(set);
    }
    return result.toSet();
}
 
Example 5
Source File: GoDescriptors.java    From buck with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static ImmutableSet<GoLinkable> requireTransitiveGoLinkables(
    BuildTarget sourceTarget,
    ActionGraphBuilder graphBuilder,
    GoPlatform platform,
    Iterable<BuildTarget> targets,
    boolean includeSelf) {
  FluentIterable<GoLinkable> linkables =
      FluentIterable.from(targets)
          .transformAndConcat(
              input -> {
                BuildTarget flavoredTarget =
                    input.withAppendedFlavors(platform.getFlavor(), TRANSITIVE_LINKABLES_FLAVOR);
                return graphBuilder.requireMetadata(flavoredTarget, ImmutableSet.class).get();
              });
  if (includeSelf) {
    Preconditions.checkArgument(sourceTarget.getFlavors().contains(TRANSITIVE_LINKABLES_FLAVOR));
    linkables =
        linkables.append(
            requireGoLinkable(
                sourceTarget,
                graphBuilder,
                platform,
                sourceTarget.withoutFlavors(TRANSITIVE_LINKABLES_FLAVOR)));
  }
  return linkables.toSet();
}
 
Example 6
Source File: MergeAndroidResourcesStep.java    From buck with Apache License 2.0 5 votes vote down vote up
public ImmutableSortedSet<Path> getRDotJavaFiles() {
  FluentIterable<String> packages =
      FluentIterable.from(
          unionPackage.map(Collections::singletonList).orElse(Collections.emptyList()));

  if (!skipNonUnionRDotJava) {
    packages =
        packages.append(
            FluentIterable.from(androidResourceDeps)
                .transform(HasAndroidResourceDeps::getRDotJavaPackage));
  }

  return packages.transform(this::getPathToRDotJava).toSortedSet(natural());
}