Example usage for com.google.common.collect FluentIterable append

List of usage examples for com.google.common.collect FluentIterable append

Introduction

In this page you can find the example usage for com.google.common.collect FluentIterable append.

Prototype

@Beta
@CheckReturnValue
public final FluentIterable<E> append(E... elements) 

Source Link

Document

Returns a fluent iterable whose iterators traverse first the elements of this fluent iterable, followed by elements .

Usage

From source file:com.facebook.buck.apple.Flavors.java

/**
 * 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.
 */// ww  w. j  a va2s  . c om
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;
}

From source file:com.facebook.buck.model.BuildTargets.java

/**
 * 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 BuildTargets to propagate the flavors to.  If a target already contains
 *             one or more flavors in domain, it is left unchanged.
 * @return the list of BuildTargets with any flavors propagated.
 *//*from   ww w.j  ava2 s  .  c o  m*/
public static FluentIterable<BuildTarget> propagateFlavorsInDomainIfNotPresent(FlavorDomain<?> domain,
        BuildTarget buildTarget, FluentIterable<BuildTarget> deps) {
    if (domain.containsAnyOf(buildTarget.getFlavors())) {
        FluentIterable<BuildTarget> targetsWithFlavorsAlready = deps
                .filter(BuildTargets.containsFlavors(domain));

        FluentIterable<BuildTarget> targetsWithoutFlavors = deps
                .filter(Predicates.not(BuildTargets.containsFlavors(domain)));

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

    return deps;
}

From source file:com.facebook.buck.features.go.GoDescriptors.java

@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();
    });/*  w w w . ja v  a2  s  .  c  om*/
    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();
}

From source file:com.facebook.buck.go.GoDescriptors.java

@SuppressWarnings("unchecked")
public static ImmutableSet<GoLinkable> requireTransitiveGoLinkables(final BuildTarget sourceTarget,
        final BuildRuleResolver resolver, final GoPlatform platform, Iterable<BuildTarget> targets,
        boolean includeSelf) throws NoSuchBuildTargetException {
    FluentIterable<GoLinkable> linkables = FluentIterable.from(targets)
            .transformAndConcat(new Function<BuildTarget, ImmutableSet<GoLinkable>>() {
                @Override/*from  w  w w  . j  a va  2 s.  c o  m*/
                public ImmutableSet<GoLinkable> apply(BuildTarget input) {
                    BuildTarget flavoredTarget = BuildTarget.builder(input)
                            .addFlavors(platform.getFlavor(), TRANSITIVE_LINKABLES_FLAVOR).build();
                    try {
                        return resolver.requireMetadata(flavoredTarget, ImmutableSet.class).get();
                    } catch (NoSuchBuildTargetException ex) {
                        throw new RuntimeException(ex);
                    }
                }
            });
    if (includeSelf) {
        Preconditions.checkArgument(sourceTarget.getFlavors().contains(TRANSITIVE_LINKABLES_FLAVOR));
        linkables = linkables.append(requireGoLinkable(sourceTarget, resolver, platform,
                sourceTarget.withoutFlavors(TRANSITIVE_LINKABLES_FLAVOR)));
    }
    return linkables.toSet();
}

From source file:com.bendb.thrifty.schema.Program.java

/**
 * Get all named elements declared in this Program.
 *//*from   w  w w.  j  a v a  2 s.  com*/
public Iterable<Named> names() {
    // Some type-resolution subtlety eludes me.  I'd have thought that
    // Iterable<EnumType> is castable to Iterable<Named> (inheritance),
    // but the IDE claims otherwise.  So, instead of FluentIterable.<Named>from(enums),
    // we work around by making one from an empty Named array and appending.
    FluentIterable<Named> iter = FluentIterable.of(new Named[0]);
    return iter.append(enums).append(structs).append(unions).append(exceptions).append(services)
            .append(typedefs);
}

From source file:org.apache.beam.runners.dataflow.worker.WindmillKeyedWorkItem.java

@Override
public Iterable<TimerData> timersIterable() {
    FluentIterable<Timer> allTimers = FluentIterable.from(workItem.getTimers().getTimersList());
    FluentIterable<Timer> eventTimers = allTimers.filter(IS_WATERMARK);
    FluentIterable<Timer> nonEventTimers = allTimers.filter(Predicates.not(IS_WATERMARK));
    return eventTimers.append(nonEventTimers).transform(timer -> WindmillTimerInternals
            .windmillTimerToTimerData(WindmillNamespacePrefix.SYSTEM_NAMESPACE_PREFIX, timer, windowCoder));
}

From source file:com.gwtplatform.processors.tools.domain.Type.java

@Override
public Collection<String> getImports() {
    FluentIterable<String> imports = from(typeArguments).transformAndConcat(EXTRACT_IMPORTS_FUNCTION);
    if (!array) {
        imports = imports.append(getQualifiedName());
    }//w  w  w .  ja  v  a2s  . c om

    return imports.toSet();
}

From source file:com.google.cloud.dataflow.sdk.runners.worker.KeyedWorkItem.java

public Iterable<TimerData> timersIterable() {
    FluentIterable<Timer> allTimers = FluentIterable.from(workItem.getTimers().getTimersList());
    FluentIterable<Timer> eventTimers = allTimers.filter(IS_WATERMARK);
    FluentIterable<Timer> nonEventTimers = allTimers.filter(Predicates.not(IS_WATERMARK));
    return eventTimers.append(nonEventTimers).transform(new Function<Timer, TimerData>() {
        private TimeDomain getTimeDomain(Windmill.Timer.Type type) {
            switch (type) {
            case REALTIME:
                return TimeDomain.PROCESSING_TIME;
            case DEPENDENT_REALTIME:
                return TimeDomain.SYNCHRONIZED_PROCESSING_TIME;
            case WATERMARK:
                return TimeDomain.EVENT_TIME;
            default:
                throw new IllegalArgumentException("Unsupported timer type " + type);
            }/*from   www .java  2  s .c o m*/
        }

        @Override
        public TimerData apply(Timer timer) {
            String tag = timer.getTag().toStringUtf8();
            String namespaceString = tag.substring(0, tag.indexOf('+'));
            StateNamespace namespace = StateNamespaces.fromString(namespaceString, windowCoder);

            Instant timestamp = new Instant(TimeUnit.MICROSECONDS.toMillis(timer.getTimestamp()));
            return TimerData.of(namespace, timestamp, getTimeDomain(timer.getType()));
        }
    });
}

From source file:com.gwtplatform.dispatch.rest.processors.details.EndPointDetails.java

@Override
public Collection<String> getImports() {
    FluentIterable<String> imports = FluentIterable.from(httpVariables)
            .transformAndConcat(EXTRACT_IMPORTS_FUNCTION).append(resultType.getImports());

    if (body.isPresent()) {
        imports = imports.append(body.get().getImports());
    }/* ww w .  j a v a 2s  .co m*/
    if (!httpVariables.isEmpty()) {
        imports = imports.append(HttpParameter.Type.class.getCanonicalName());
    }

    return imports.filter(and(notNull(), not(equalTo("")))).toList();
}

From source file:com.gwtplatform.mvp.processors.proxy.AbstractProxyDetails.java

@Override
public Collection<String> getImports() {
    FluentIterable<String> imports = from(getProxyEventMethods())
            .transformAndConcat(HasImports.EXTRACT_IMPORTS_FUNCTION).append(getProxyType().getImports())
            .append(getPresenterType().getImports());

    if (getBundleDetails() != null) {
        imports = imports.append(getBundleDetails().getImports());
    }/*from w  w w .  j  a v  a2 s  .  c o m*/
    if (getCustomProvider() != null) {
        imports = imports.append(getCustomProvider().getImports());
    }

    return imports.toList();
}