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:net.oneandone.maven.plugins.cycles.graph.FeedbackArcSet.java

private static <V, E> Ordering<V> vertexOrdering(DirectedGraph<V, E> graph,
        VertexEvaluator<V, DirectedGraph<V, E>> evaluator) {
    List<V> front = Lists.newLinkedList();
    List<V> back = Lists.newLinkedList();

    // FIXME: there must be an easier way to clone a graph
    DirectedGraph<V, E> g = FilterUtils.createInducedSubgraph(graph.getVertices(), graph);

    while (!g.getVertices().isEmpty()) {
        collectSinks(g, back);/*  www  . j a va 2  s  . c o m*/
        collectSources(g, front);
        collectMaxDelta(g, front, evaluator);
    }

    return Ordering.explicit(Lists.newArrayList(Iterables.concat(front, back)));
}

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

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

From source file:org.inferred.freebuilder.processor.util.CompilationUnitWriter.java

private static Iterable<TypeElement> siblingTypes(TypeElement type) {
    return Iterables.concat(ImmutableList.of(type), typesIn(type.getEnclosingElement().getEnclosedElements()));
}

From source file:org.summer.dsl.model.ui.notification.LayeredTypeResourceDescription.java

public Iterable<IEObjectDescription> getExportedObjectsByType(final EClass type) {
    Iterable<IEObjectDescription> additionallyFiltered = Iterables.filter(additionallyExported,
            new Predicate<IEObjectDescription>() {
                public boolean apply(IEObjectDescription input) {
                    return EcoreUtil2.isAssignableFrom(type, input.getEClass());
                }/* w  w w  . j  a va2s.  co m*/
            });
    return Iterables.concat(delegate.getExportedObjectsByType(type), additionallyFiltered);
}

From source file:com.torodb.torod.core.language.AttributeReference.java

public AttributeReference prepend(List<? extends Key> head) {
    return new AttributeReference(ImmutableList.copyOf(Iterables.concat(head, this.keys)));
}

From source file:com.torodb.core.language.AttributeReference.java

public AttributeReference prepend(List<? extends Key<?>> head) {
    return new AttributeReference(ImmutableList.copyOf(Iterables.concat(head, this.keys)));
}

From source file:org.graylog2.rest.SearchResponseCsvWriter.java

@Override
public void writeTo(SearchResponse searchResponse, Class<?> type, Type genericType, Annotation[] annotations,
        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
        throws IOException, WebApplicationException {
    final CSVWriter csvWriter = new CSVWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
    final ImmutableSortedSet<String> sortedFields = ImmutableSortedSet
            .copyOf(Iterables.concat(searchResponse.fields(), Lists.newArrayList("source", "timestamp")));

    // write field headers
    csvWriter.writeNext(sortedFields.toArray(new String[sortedFields.size()]));

    // write result set in same order as the header row
    final String[] fieldValues = new String[sortedFields.size()];
    for (ResultMessageSummary message : searchResponse.messages()) {
        int idx = 0;
        // first collect all values from the current message
        for (String fieldName : sortedFields) {
            final Object val = message.message().get(fieldName);
            fieldValues[idx++] = ((val == null) ? null : val.toString().replaceAll("\n", "\\\\n"));
            fieldValues[idx++] = ((val == null) ? null : val.toString().replaceAll("\r", "\\\\r"));
        }/*from   w  ww  .  j  a v a 2  s  . c om*/
        // write the complete line, some fields might not be present in the message, so there might be null values
        csvWriter.writeNext(fieldValues);
    }
    if (csvWriter.checkError()) {
        LOG.error(
                "Encountered unspecified error when writing message result as CSV, result is likely malformed.");
    }
    csvWriter.close();
}

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

@Override
protected boolean canReportCycle(SkyKey topLevelKey, CycleInfo cycleInfo) {
    if (!IS_CONFIGURED_TARGET_SKY_KEY.apply(topLevelKey)) {
        return false;
    }// w ww . j av  a2  s  . c o m
    Iterable<SkyKey> cycleKeys = Iterables.concat(cycleInfo.getPathToCycle(), cycleInfo.getCycle());
    // Static configurations expect all keys to be ConfiguredTargetValue keys. Dynamic
    // configurations expect the top-level key to be a ConfiguredTargetValue key, but cycles and
    // paths to them can travel through TransitiveTargetValue keys because ConfiguredTargetFunction
    // visits TransitiveTargetFunction as a part of dynamic configuration computation.
    //
    // Unfortunately this class can't easily figure out if we're in static or dynamic configuration
    // mode, so we loosely permit both cases.
    //
    // TODO: remove the static-style checking once dynamic configurations fully replace them
    return Iterables.all(cycleKeys,
            Predicates.<SkyKey>or(IS_CONFIGURED_TARGET_SKY_KEY, IS_TRANSITIVE_TARGET_SKY_KEY));
}

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

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

From source file:com.opengamma.engine.depgraph.SimpleResolutionFailureVisitor.java

@Override
protected List<ResolutionFailure> visitFailedFunction(ValueRequirement valueRequirement, String function,
        ValueSpecification desiredOutput, Map<ValueSpecification, ValueRequirement> satisfied,
        Set<ResolutionFailure> unsatisfied, Set<ResolutionFailure> unsatisfiedAdditional) {
    return ImmutableList.copyOf(Iterables.concat(unsatisfied, unsatisfiedAdditional));
}