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.synflow.cx.scoping.CxScopeProvider.java

private Iterable<IEObjectDescription> getAllPortDescs(Network network, String direction) {
    Iterable<IEObjectDescription> descriptions = getPortDescs(network, direction);

    // invert direction when referencing ports in instances
    direction = direction == DIR_IN ? DIR_OUT : DIR_IN;
    for (final Inst inst : network.getInstances()) {
        descriptions = Iterables.concat(descriptions, getPortDescs(inst, direction));
    }/*from   www.  j  a  v a  2  s .  com*/
    return descriptions;
}

From source file:com.facebook.buck.java.intellij.ExportedDepsClosureResolver.java

/**
 * @param buildTarget target to process.
 * @return the set of {@link BuildTarget}s that must be appended to the
 *         dependencies of a node Y if node Y depends on X.
 */// ww w. ja va2  s.c  o  m
public ImmutableSet<BuildTarget> getExportedDepsClosure(BuildTarget buildTarget) {
    if (index.containsKey(buildTarget)) {
        return index.get(buildTarget);
    }

    ImmutableSet<BuildTarget> exportedDeps = ImmutableSet.of();
    TargetNode<?> targetNode = Preconditions.checkNotNull(targetGraph.get(buildTarget));
    if (targetNode.getType().equals(JavaLibraryDescription.TYPE)) {
        JavaLibraryDescription.Arg arg = (JavaLibraryDescription.Arg) targetNode.getConstructorArg();
        exportedDeps = arg.exportedDeps.get();
    } else if (targetNode.getType().equals(AndroidLibraryDescription.TYPE)) {
        AndroidLibraryDescription.Arg arg = (AndroidLibraryDescription.Arg) targetNode.getConstructorArg();
        exportedDeps = arg.exportedDeps.get();
    }

    ImmutableSet<BuildTarget> exportedDepsClosure = FluentIterable.from(exportedDeps)
            .transformAndConcat(new Function<BuildTarget, Iterable<BuildTarget>>() {
                @Override
                public Iterable<BuildTarget> apply(BuildTarget input) {
                    return Iterables.concat(ImmutableSet.of(input), getExportedDepsClosure(input));
                }
            }).toSet();
    index.put(buildTarget, exportedDepsClosure);
    return exportedDepsClosure;
}

From source file:org.eclipse.xtext.resource.containers.DescriptionAddingContainer.java

@Override
public Iterable<IEObjectDescription> getExportedObjectsByType(EClass type) {
    Iterable<IEObjectDescription> added = description.getExportedObjectsByType(type);
    Iterable<IEObjectDescription> delegated = delegate.getExportedObjectsByType(type);
    return Iterables.concat(added, delegated);
}

From source file:org.eclipse.emf.eson.scoping.EPackageScopeProvider.java

private <T extends EObject> Iterable<T> getAllInstances(Iterable<? extends EPackage> ePackages, Class<T> type) {
    Iterable<T> result = Collections.emptyList();
    for (EPackage ePackage : ePackages) {
        List<T> allContents = EcoreUtil2.getAllContentsOfType(ePackage, type);
        result = Iterables.concat(result, allContents);
    }//from w  w w . j a va  2 s .  c o m
    return result;
}

From source file:com.github.alechenninger.teamwork.Teamwork.java

public Teamwork(UriFactory uriFactory, CamelContext teamworkContext) {
    this.uriFactory = Objects.requireNonNull(uriFactory, "uriFactory");
    this.teamworkContext = Objects.requireNonNull(teamworkContext, "teamworkContext");

    teamworkContext.addLifecycleStrategy(new LinkedCamelContextLifecycleStrategy(
            Iterables.concat(producerContexts.values(), consumerContexts.values())));
}

From source file:com.google.gerrit.server.account.AccountLoader.java

public void fill() throws OrmException {
    try {/* ww w.  j a v  a 2 s .c o  m*/
        directory.fillAccountInfo(Iterables.concat(created.values(), provided), options);
    } catch (DirectoryException e) {
        Throwables.throwIfInstanceOf(e.getCause(), OrmException.class);
        throw new OrmException(e);
    }
}

From source file:net.hydromatic.optiq.rules.java.EnumerableRelImplementor.java

public ClassDeclaration implementRoot(EnumerableRel rootRel, EnumerableRel.Prefer prefer) {
    final EnumerableRel.Result result = rootRel.implement(this, prefer);
    List<MemberDeclaration> memberDeclarations = new ArrayList<MemberDeclaration>();
    declareSyntheticClasses(result.block, memberDeclarations);

    // The following is a workaround to
    // http://jira.codehaus.org/browse/JANINO-169. Otherwise we'd remove the
    // member variable, rename the "root0" parameter as "root", and reference it
    // directly from inner classes.
    final ParameterExpression root0_ = Expressions.parameter(Modifier.FINAL, DataContext.class, "root0");
    final BlockStatement block = Expressions.block(Iterables.concat(
            ImmutableList.of(Expressions.statement(Expressions.assign(DataContext.ROOT, root0_))),
            result.block.statements));//from ww w  .j av  a2  s  .  c  o m
    memberDeclarations.add(Expressions.fieldDecl(0, DataContext.ROOT, null));

    memberDeclarations.add(Expressions.methodDecl(Modifier.PUBLIC, Enumerable.class,
            BuiltinMethod.BINDABLE_BIND.method.getName(), Expressions.list(root0_), block));
    memberDeclarations.add(Expressions.methodDecl(Modifier.PUBLIC, Type.class,
            BuiltinMethod.TYPED_GET_ELEMENT_TYPE.method.getName(), Collections.<ParameterExpression>emptyList(),
            Blocks.toFunctionBlock(
                    Expressions.return_(null, Expressions.constant(result.physType.getJavaRowType())))));
    return Expressions.classDecl(Modifier.PUBLIC, "Baz", null, Collections.<Type>singletonList(Bindable.class),
            memberDeclarations);
}

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

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

From source file:com.careerly.common.support.msgconverter.CsvHttpMessageConverter.java

@Override
protected void writeInternal(CsvResponse t, HttpOutputMessage outputMessage)
        throws IOException, HttpMessageNotWritableException {
    ServletServerHttpResponse response = (ServletServerHttpResponse) outputMessage;
    response.getServletResponse().setCharacterEncoding("UTF-8");
    outputMessage.getHeaders().set("Content-Disposition", "attachment; filename=\"" + t.getFileName() + "\"");
    BufferedWriter bw = new BufferedWriter(
            new OutputStreamWriter(outputMessage.getBody(), Charset.forName("UTF-8")));
    try {// w w  w  .  j  a  va2s .co  m
        for (List<String> line : Iterables.concat(Collections.singleton(t.getHead()), t.getBody())) {
            for (int i = 0; i < line.size(); i++) {
                if (line.get(i) != null) {
                    bw.write("\"");
                    bw.write(line.get(i));
                    bw.write("\"");
                }
                if (i < line.size() - 1) {
                    bw.write(seperator);
                }
            }
            bw.newLine();
        }
    } finally {
        bw.close();
    }
}

From source file:net.hydromatic.optiq.prepare.OptiqCatalogReader.java

private OptiqPrepareImpl.RelOptTableImpl getTableFrom(List<String> names, List<String> schemaNames) {
    OptiqSchema schema = getSchema(Iterables.concat(schemaNames, Util.skipLast(names)));
    if (schema == null) {
        return null;
    }//from   w w  w .  j a  va  2  s  . com
    final String name = Util.last(names);
    final Table table = schema.compositeTableMap.get(name);
    if (table != null) {
        return new OptiqPrepareImpl.RelOptTableImpl(this, table.getRowType(typeFactory),
                schema.add(name, table));
    }
    return null;
}