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:org.eclipse.viatra.addon.viewers.runtime.zest.sources.ZestContentProvider.java

@Override
public Object[] getElements(Object inputElement) {
    if (state != null) {
        Iterable<Edge> it = (displayContainment) ? Iterables.concat(state.getEdges(), state.getContainments())
                : state.getEdges();//from   w  ww. j  a va2 s.  c om
        return Iterables.toArray(it, Edge.class);
    } else
        return new Object[] {};
}

From source file:com.google.devtools.build.lib.skyframe.BuildTargetPatternsResultBuilder.java

@Override
protected Iterable<Label> getLabels() {
    ResolvedTargets<Label> resolvedLabels = resolvedLabelsBuilder.build();
    return Iterables.concat(resolvedLabels.getTargets(), resolvedLabels.getFilteredTargets());
}

From source file:org.gradle.api.internal.tasks.compile.CommandLineJavaCompilerArgumentsGenerator.java

public Iterable<String> generate(JavaCompileSpec spec) {
    List<String> launcherOptions = new JavaCompilerArgumentsBuilder(spec).includeLauncherOptions(true)
            .includeMainOptions(false).includeClasspath(false).includeCustomizations(false).build();
    List<String> remainingArgs = new JavaCompilerArgumentsBuilder(spec).includeSourceFiles(true).build();
    Iterable<String> allArgs = Iterables.concat(launcherOptions, remainingArgs);
    if (exceedsWindowsCommandLineLengthLimit(allArgs)) {
        return Iterables.concat(launcherOptions, shortenArgs(spec.getTempDir(), remainingArgs));
    }//  w w w  .  java2  s .co m
    return allArgs;
}

From source file:org.eclipse.elk.tree.TreeUtil.java

/**
 * This method returns the leftmost node at the given level. This is implemented using a
 * postorder walk of the subtree under given level, depth levels down. Depth here refers to the
 * level below where the leftmost descendant is being found.
 * /*from   w w  w  . j av a 2 s . c o  m*/
 * If given level is negative it returns the leftmost node at the deepest level.
 * 
 * @param currentlevel
 *            a list of nodes at level one
 * @param depth
 *            the depth to search for
 * @return the leftmost descendant at depth levels down
 */
public static TNode getLeftMost(final Iterable<TNode> currentlevel, final int depth) {
    if (0 < Iterables.size(currentlevel)) {
        int d = depth;

        // the leftmost descendant at depth levels down
        if (1 < d) {
            d--;
            // build empty iterator
            Iterable<TNode> nextLevel = new Iterable<TNode>() {

                public Iterator<TNode> iterator() {
                    return Iterators.emptyIterator();
                }
            };

            for (TNode cN : currentlevel) {
                // append the children of the current node to the next level
                nextLevel = Iterables.concat(nextLevel, cN.getChildren());
            }
            return getLeftMost(nextLevel, d);
        }

        // the leftmost node at the deepest level
        if (d < 0) {
            // build empty iterator
            Iterable<TNode> nextLevel = new Iterable<TNode>() {

                public Iterator<TNode> iterator() {
                    return Iterators.emptyIterator();
                }
            };

            for (TNode cN : currentlevel) {
                // append the children of the current node to the next level
                nextLevel = Iterables.concat(nextLevel, cN.getChildren());
            }

            //
            if (0 < Iterables.size(nextLevel)) {
                return getLeftMost(nextLevel, d);
            }
        }
    }
    // return the leftmost node at the current level
    return Iterables.getFirst(currentlevel, null);
}

From source file:org.apache.cassandra.cql3.functions.FunctionCall.java

public Iterable<Function> getFunctions() {
    return Iterables.concat(Terms.getFunctions(terms), fun.getFunctions());
}

From source file:org.jetbrains.kotlin.codegen.inline.Parameters.java

@NotNull
@Override
public Iterator<ParameterInfo> iterator() {
    return Iterables.concat(real, captured).iterator();
}

From source file:org.elasticsearch.common.inject.internal.SourceProvider.java

/**
 * Returns a new instance that also skips {@code moreClassesToSkip}.
 *//*from w w w.j av  a2  s.  c o  m*/
public SourceProvider plusSkippedClasses(Class... moreClassesToSkip) {
    return new SourceProvider(Iterables.concat(classNamesToSkip, asStrings(moreClassesToSkip)));
}

From source file:org.richfaces.cdk.templatecompiler.builder.model.JavaField.java

@Override
public Iterable<JavaImport> getRequiredImports() {
    Iterable<JavaImport> imports = super.getRequiredImports();
    return Iterables.concat(getType().getRequiredImports(), imports);
}

From source file:iterator.util.Utils.java

/**
 * Concatenates a series of optional elements onto an initial {@link List}.
 *
 * <pre>//  w w w.  j a  v a  2 s .c o m
 * {@code List<Transform> all = concatenate(ifs, selected);}
 * </pre>
 *
 * @param initial the initial {@link List}
 * @param optional a series of optional elements that may be null
 * @return a new {@link List} including the non-null optional elements
 * @see Iterables#concat(Iterable)
 * @see Optional#asSet()
 */
@SafeVarargs
public static <T> List<T> concatenate(List<T> initial, T... optional) {
    List<Set<T>> extra = Lists.newArrayList();
    for (T nullable : optional) {
        extra.add(Optional.fromNullable(nullable).asSet());
    }
    Iterable<T> joined = Iterables.concat(initial, Iterables.concat(extra));
    return Lists.newArrayList(joined);
}

From source file:org.gradle.api.internal.tasks.compile.incremental.recomp.CurrentCompilation.java

public ClasspathSnapshot getClasspathSnapshot() {
    return classpathSnapshotProvider
            .getClasspathSnapshot(Iterables.concat(spec.getCompileClasspath(), spec.getModulePath()));
}