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.google.javascript.jscomp.debugger.gwt.DebuggerGwtMain.java

private void updateUi(Compiler compiler, Result result) {
    rightPane.clear();/*w  w w .  j  ava2  s .  co m*/
    rightPane.add(new HTML("<h4>Output</h4>"));
    String outputCode = compiler.toSource();
    rightPane.add(new Label(outputCode));
    rightPane.add(new HTML("<h4>Warnings</h4>"));
    List<JSError> errors = Arrays.asList(result.errors);
    List<JSError> warnings = Arrays.asList(result.warnings);
    rightPane.add(new Label(Joiner.on("\n\n").join(Iterables.concat(errors, warnings))));
    rightPane.add(new HTML("<h4>AST</h4>"));
    String outputAst = compiler.getRoot().toStringTree();
    rightPane.add(new Label(outputAst));
}

From source file:com.proofpoint.reporting.MetricsResource.java

@GET
@AccessDoesNotRequireAuthentication//from w  ww.  jav a 2s  . c o  m
@Produces("text/plain; version=0.0.4; charset=utf-8")
public StreamingOutput getMetrics() {
    return output -> {
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8))) {
            for (Entry<String, Collection<TaggedValue>> entry : prometheusCollector.collectData().asMap()
                    .entrySet()) {
                boolean first = true;

                for (TaggedValue taggedValue : entry.getValue()) {
                    if (first) {
                        first = false;
                        writer.write("#TYPE ");
                        writer.write(entry.getKey());
                        writer.write(" gauge\n");
                    }

                    taggedValue.getValueAndTimestamp().getValue().writeMetric(writer, entry.getKey(),
                            Iterables.concat(taggedValue.getTags().entrySet(), instanceTags.entrySet()),
                            taggedValue.getValueAndTimestamp().getTimestamp());
                }
            }
        }
    };
}

From source file:com.synflow.cx.internal.services.VoidCxSwitch.java

@Override
public Void caseExpressionVariable(ExpressionVariable expr) {
    return visit(this, Iterables.concat(expr.getIndexes(), expr.getParameters()));
}

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

@Override
public Iterable<JavaField> getRequiredFields() {
    parse();
    return Iterables.concat(super.getRequiredFields(), fields);
}

From source file:org.polarsys.reqcycle.utils.collect.collectors.WidthCollector.java

/**
 * Width wise collection.//from   w  ww  .j  a v  a2  s  .  c  o  m
 * 
 * @param handler
 *            the handler that processes each element.
 * @param element
 *            : the current layer from which the collection is performed.
 * @throws CollectionAbortedException
 */
protected void collectWidthWise(ResultHandler<T> handler, Iterable<T> currentLayer)
        throws CollectionAbortedException {
    Iterable<T> nextLayer = Collections.emptyList();
    while (currentLayer != null && !Iterables.isEmpty(currentLayer)) {
        for (T currentElement : currentLayer) {
            try {
                handler.handleResult(currentElement);
                // Building the next layer.
                for (Picker<T> picker : this.getPickers()) {
                    Iterable<T> nexts = picker.getNexts(currentElement); // getting children.
                    if (nexts != null) {
                        nextLayer = Iterables.concat(nextLayer, nexts);
                    }
                }
            } catch (CannotHandleException e) {
                // do nothing
            } catch (Exception e) {
                throw new CollectionAbortedException(e);
            }
        }
        // The current layer has been processed. Going through the next one.
        currentLayer = nextLayer;
        nextLayer = Collections.emptyList();
    }
}

From source file:com.android.build.gradle.tasks.StripDependenciesTask.java

@SuppressWarnings("unused") // Used by incremental task action.
@InputFiles//from   w  ww  . j av  a2s  . com
Iterable<File> getInputFiles() {
    return Iterables.concat(stripedFiles.keySet(), inputFiles.keySet());
}

From source file:org.glowroot.local.ui.TraceCommonService.java

@Nullable
CharSource getEntries(String traceId) throws SQLException {
    // check active traces first, then pending traces, and finally stored traces
    // to make sure that the trace is not missed if it is in transition between these states
    for (Transaction transaction : Iterables.concat(transactionRegistry.getTransactions(),
            transactionCollectorImpl.getPendingTransactions())) {
        if (transaction.getId().equals(traceId)) {
            return createEntries(transaction);
        }//w  ww . ja  va2 s  .c om
    }
    return traceDao.readEntries(traceId);
}

From source file:com.netflix.servo.tag.BasicTagList.java

/**
 * Returns a tag list containing the union of {@code t1} and {@code t2}.
 * If there is a conflict with tag keys, the tag from {@code t2} will be
 * used.//from   w ww  .j  a  v  a  2 s  .  c o m
 */
public static BasicTagList concat(TagList t1, TagList t2) {
    return new BasicTagList(Iterables.concat(t1, t2));
}

From source file:org.glowroot.agent.live.LiveTraceRepositoryImpl.java

@Override
public Trace. /*@Nullable*/ Header getHeader(String agentId, String traceId) {
    for (Transaction transaction : Iterables.concat(transactionRegistry.getTransactions(),
            traceCollector.getPendingTransactions())) {
        if (transaction.getTraceId().equals(traceId)) {
            return createTraceHeader(transaction);
        }/*from w  w  w. jav  a  2 s  .c om*/
    }
    return null;
}

From source file:org.janusgraph.graphdb.log.StandardChangeState.java

private Iterable<JanusGraphRelation> getRelations(final Change change,
        final Predicate<JanusGraphRelation> filter) {
    Iterable<JanusGraphRelation> base;
    if (change.isProper())
        base = relations.get(change);//  ww  w  .j  a v a  2  s .  c om
    else
        base = Iterables.concat(relations.get(Change.ADDED), relations.get(Change.REMOVED));
    return Iterables.filter(base, filter);
}