Example usage for com.google.common.collect Iterables concat

List of usage examples for com.google.common.collect Iterables concat

Introduction

In this page you can find the example usage for com.google.common.collect Iterables concat.

Prototype

public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) 

Source Link

Document

Combines two iterables into a single iterable.

Usage

From source file:com.pressassociation.pr.ast.visitor.FindFieldsVisitor.java

private Iterable<Field> getFields() {
    if (result.isEmpty()) {
        checkState(last != null, "Cannot get the result if the visitor hasn't been used");
        return ImmutableList.of(last);
    }/*w  ww  . j a va 2  s. co  m*/
    List<Field> allButLast = Lists.transform(result, new Function<Fields, Field>() {
        @Override
        public Field apply(Fields input) {
            return input.getField();
        }
    });
    return Iterables.concat(ImmutableList.of(getEnd()), Lists.reverse(allButLast));
}

From source file:com.puppetlabs.geppetto.graph.catalog.AbstractCatalogGraphProducer.java

/**
 * Adds "exported" and "virtual" as pseudo parameters if they are set to true.
 * /* ww  w. j  av  a 2  s. co m*/
 * @param r
 * @return
 */
protected Iterable<CatalogResourceParameter> getParameterIterable(CatalogResource r) {
    Iterable<CatalogResourceParameter> result = r.getParameters();
    if (r.isExported() || r.isVirtual()) {
        if (r.isExported()) {
            CatalogResourceParameter p = CatalogFactory.eINSTANCE.createCatalogResourceParameter();
            p.setName("exported");
            p.getValue().add("true");
            result = Iterables.concat(result, Collections.singleton(p));
        }
        if (r.isVirtual()) {
            CatalogResourceParameter p = CatalogFactory.eINSTANCE.createCatalogResourceParameter();
            p.setName("virtual");
            p.getValue().add("true");
            result = Iterables.concat(result, Collections.singleton(p));
        }
    }
    return result;
}

From source file:sg.atom.utils._beta.functional.FunctionalIterable.java

public FunctionalIterable<T> concat(Iterable<Iterable<T>> toConcat) {
    return new FunctionalIterable<T>(Iterables.concat(delegate, Iterables.concat(toConcat)));
}

From source file:org.janusgraph.graphdb.types.vertices.RelationTypeVertex.java

public Iterable<InternalRelationType> getRelationIndexes() {
    return Iterables.concat(ImmutableList.of(this),
            Iterables.transform(getRelated(TypeDefinitionCategory.RELATIONTYPE_INDEX, Direction.OUT),
                    new Function<Entry, InternalRelationType>() {
                        @Nullable// w w w.  j  av  a2 s  . co m
                        @Override
                        public InternalRelationType apply(@Nullable Entry entry) {
                            assert entry.getSchemaType() instanceof InternalRelationType;
                            return (InternalRelationType) entry.getSchemaType();
                        }
                    }));
}

From source file:com.facebook.buck.cxx.AbstractNativeBuildRule.java

@Override
public ImmutableCollection<Path> getInputsToCompareToOutput() {
    return SourcePaths.filterInputsToCompareToOutput(Iterables.concat(srcs, headers));
}

From source file:eu.lp0.cursus.ui.component.EnumDatabaseColumn.java

private List<Object> generateValues() {
    Iterable<Object> constants = Iterables
            .transform(Iterables.filter(Arrays.asList(type.getEnumConstants()), new Predicate<V>() {
                @Override// w  w w  .j  av a2  s. c om
                public boolean apply(V input) {
                    return !isTransient(input);
                }
            }), new Function<V, Object>() {
                @Override
                public Object apply(V input) {
                    return new WrappedEnum(input);
                }
            });

    if (nullable) {
        return Lists.<Object>newArrayList(Iterables.concat(Collections.singletonList(""), constants)); //$NON-NLS-1$
    } else {
        return Lists.<Object>newArrayList(constants);
    }
}

From source file:com.google.devtools.build.lib.analysis.actions.CommandLine.java

/**
 * Returns a {@link CommandLine} that is constructed by prepending the {@code executableArgs} to
 * {@code commandLine}./* ww  w . j  av a2 s.com*/
 */
static CommandLine ofMixed(final ImmutableList<String> executableArgs, final CommandLine commandLine,
        final boolean isShellCommand) {
    Preconditions.checkState(!executableArgs.isEmpty());
    return new CommandLine() {
        @Override
        public Iterable<String> arguments() {
            return Iterables.concat(executableArgs, commandLine.arguments());
        }

        @Override
        public Iterable<String> arguments(ArtifactExpander artifactExpander) {
            return Iterables.concat(executableArgs, commandLine.arguments(artifactExpander));
        }

        @Override
        public boolean isShellCommand() {
            return isShellCommand;
        }
    };
}

From source file:com.facebook.buck.haskell.HaskellPackageRule.java

public static HaskellPackageRule from(BuildTarget target, BuildRuleParams baseParams,
        final SourcePathResolver resolver, SourcePathRuleFinder ruleFinder, final Tool ghcPkg,
        HaskellVersion haskellVersion, HaskellPackageInfo packageInfo,
        final ImmutableSortedMap<String, HaskellPackage> depPackages, ImmutableSortedSet<String> modules,
        final ImmutableSortedSet<SourcePath> libraries, final ImmutableSortedSet<SourcePath> interfaces) {
    return new HaskellPackageRule(
            baseParams.copyWithChanges(target, Suppliers.memoize(() -> ImmutableSortedSet
                    .<BuildRule>naturalOrder().addAll(ghcPkg.getDeps(ruleFinder))
                    .addAll(depPackages.values().stream().flatMap(pkg -> pkg.getDeps(ruleFinder)).iterator())
                    .addAll(ruleFinder.filterBuildRuleInputs(Iterables.concat(libraries, interfaces))).build()),
                    Suppliers.ofInstance(ImmutableSortedSet.of())),
            resolver, ghcPkg, haskellVersion, packageInfo, depPackages, modules, libraries, interfaces);
}

From source file:org.richfaces.cdk.templatecompiler.statements.FreeMarkerTemplateStatementBase.java

@Override
public Iterable<HelperMethod> getRequiredMethods() {
    parse();
    return Iterables.concat(super.getRequiredMethods(), requiredMethods);
}

From source file:org.gradle.model.internal.core.DefaultNodeInitializerRegistry.java

public ModelTypeInitializationException canNotConstructTypeException(NodeInitializerContext context) {
    Iterable<ModelType<?>> scalars = Iterables.concat(ScalarTypes.TYPES, ScalarTypes.NON_FINAL_TYPES);
    Set<ModelType<?>> constructableTypes = new TreeSet<ModelType<?>>(new Comparator<ModelType<?>>() {
        @Override//  w  ww  .  j av a 2 s  .  co  m
        public int compare(ModelType<?> o1, ModelType<?> o2) {
            return o1.getDisplayName().compareTo(o2.getDisplayName());
        }
    });
    for (NodeInitializerExtractionStrategy extractor : additionalStrategies) {
        Iterables.addAll(constructableTypes, extractor.supportedTypes());
    }
    return new ModelTypeInitializationException(context, schemaStore, scalars, constructableTypes);
}