Example usage for com.google.common.collect ImmutableList stream

List of usage examples for com.google.common.collect ImmutableList stream

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList stream.

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:com.spectralogic.ds3contractcomparator.print.htmlprinter.HtmlReportPrinter.java

/**
 * Creates the index table entries representing all {@link Ds3TypeDiff}
 *//*from ww w.  java  2  s . co  m*/
private static ImmutableList<IndexEntry> toTypeIndexEntryList(
        final ImmutableList<AbstractDs3TypeDiff> typeDiffs,
        final Class<? extends AbstractDs3TypeDiff> typeClass) {
    return typeDiffs.stream().filter(t -> t.getClass() == typeClass).map(HtmlReportPrinter::toTypeIndexEntry)
            .collect(GuavaCollectors.immutableList());
}

From source file:com.spectralogic.ds3autogen.net.NetHelper.java

/**
 * Creates a comma separated list of strings with the specified indentation.
 * Used in Net model generation./*  w  ww  .  ja va 2s. c  o  m*/
 */
public static String commaSeparateStrings(final ImmutableList<String> strings, final int indent) {
    if (isEmpty(strings)) {
        return "";
    }
    return strings.stream().collect(Collectors.joining(",\n" + indent(indent)));
}

From source file:com.spectralogic.ds3autogen.c.helpers.RequestHelper.java

public static String paramListToString(final ImmutableList<Parameter> paramList) {
    if (isEmpty(paramList)) {
        return "";
    }/*from   ww  w. j ava2s .c  om*/

    return paramList.stream().map(Parameter::toString).collect(Collectors.joining(", "));
}

From source file:com.spectralogic.ds3contractcomparator.print.htmlprinter.HtmlReportPrinter.java

/**
 * Creates the report tables for the specified type of {@link AbstractDs3RequestDiff}
 *//* ww w .  jav a  2  s .  com*/
private static ImmutableList<Table> toRequestTableList(final ImmutableList<AbstractDs3RequestDiff> requestDiffs,
        final Class<? extends AbstractDs3RequestDiff> requestClass) {
    return requestDiffs.stream().filter(r -> r.getClass() == requestClass)
            .map(HtmlRequestTableGenerator::toRequestTable).collect(GuavaCollectors.immutableList());
}

From source file:com.spectralogic.ds3contractcomparator.print.htmlprinter.HtmlReportPrinter.java

/**
 * Creates the index table entries for all {@link Ds3RequestDiff}
 *///  w w w  . j  ava  2 s.  c  om
private static ImmutableList<IndexEntry> toRequestIndexEntryList(
        final ImmutableList<AbstractDs3RequestDiff> requestDiffs,
        final Class<? extends AbstractDs3RequestDiff> requestClass) {
    return requestDiffs.stream().filter(r -> r.getClass() == requestClass)
            .map(HtmlReportPrinter::toRequestIndexEntry).collect(GuavaCollectors.immutableList());
}

From source file:com.spectralogic.ds3autogen.java.converters.ClientConverter.java

/**
 * Creates a list of Custom Commands from the Ds3Request list assuming
 * that the request list contains custom commands.
 *///from  w w w  .  j  av a  2s.c  om
protected static ImmutableList<CustomCommand> toCustomCommandList(final ImmutableList<Ds3Request> ds3Requests,
        final Ds3DocSpec docSpec) {
    if (isEmpty(ds3Requests)) {
        return ImmutableList.of();
    }
    return ds3Requests.stream().filter(ClientConverter::isCustomCommand)
            .map(request -> toCustomCommand(request, docSpec)).collect(GuavaCollectors.immutableList());
}

From source file:com.spectralogic.ds3autogen.java.converters.ClientConverter.java

/**
 * Converts a list of Ds3Requests into a list of Commands
 * @param ds3Requests List of Ds3Requests
 * @return A list of Commands//from w ww . j  a  v a2  s. c om
 */
protected static ImmutableList<Command> toCommandList(final ImmutableList<Ds3Request> ds3Requests,
        final Ds3DocSpec docSpec) {
    if (isEmpty(ds3Requests)) {
        return ImmutableList.of();
    }
    return ds3Requests.stream().filter(ds3Request -> !isCustomCommand(ds3Request))
            .map(ds3Request -> toCommand(ds3Request, docSpec)).collect(GuavaCollectors.immutableList());
}

From source file:com.spectralogic.ds3autogen.net.NetHelper.java

/**
 * Creates a comma separated list of enum constants. Used in Java model generation.
 *//*from  w ww.j a  va 2s. c o  m*/
public static String getEnumValues(final ImmutableList<EnumConstant> enumConstants, final int indent) {
    if (isEmpty(enumConstants)) {
        return "";
    }
    return enumConstants.stream().map(i -> indent(indent) + i.getName()).collect(Collectors.joining(",\n"));
}

From source file:com.spectralogic.ds3autogen.net.generators.clientmodels.BaseClientGenerator.java

/**
 * Creates the list of specialized commands for the client
 *//*www .  java2  s  .  c om*/
protected static ImmutableList<SpecializedCommand> toSpecializedCommands(
        final ImmutableList<Ds3Request> ds3Requests, final Ds3DocSpec docSpec) {
    if (isEmpty(ds3Requests)) {
        return ImmutableList.of();
    }
    return ds3Requests.stream().filter(Ds3RequestClassificationUtil::isGetObjectAmazonS3Request)
            .map(request -> toGetObjectCommand(request, docSpec)).collect(GuavaCollectors.immutableList());
}

From source file:ai.grakn.graql.internal.reasoner.ResolutionPlan.java

/**
 * compute the resolution plan - list of atomic queries ordered by their cost as computed by the graql traversal planner
 * @return list of prioritised queries//from w w w. j a v a 2s  .  c o m
 */
public static LinkedList<ReasonerQueryImpl> getResolutionPlanFromTraversal(ReasonerQueryImpl query) {
    LinkedList<ReasonerQueryImpl> queries = new LinkedList<>();
    GraknGraph graph = query.graph();

    Map<VarProperty, Atom> propertyMap = new HashMap<>();
    query.getAtoms().stream().filter(Atomic::isSelectable).map(at -> (Atom) at)
            .forEach(at -> at.getVarProperties().forEach(p -> propertyMap.put(p, at)));
    Set<VarProperty> properties = propertyMap.keySet();

    GraqlTraversal graqlTraversal = GreedyTraversalPlan.createTraversal(query.getPattern(), graph);
    ImmutableList<Fragment> fragments = graqlTraversal.fragments().iterator().next();

    LinkedList<Atom> atoms = fragments.stream().map(Fragment::getVarProperty).filter(Objects::nonNull)
            .filter(properties::contains).distinct().map(propertyMap::get).distinct()
            .collect(Collectors.toCollection(LinkedList::new));

    Set<Atom> nonResolvableAtoms = new HashSet<>();
    while (!atoms.isEmpty()) {
        Atom top = atoms.remove();
        if (top.isRuleResolvable()) {
            if (!nonResolvableAtoms.isEmpty()) {
                queries.add(ReasonerQueries.create(nonResolvableAtoms, graph));
                nonResolvableAtoms.clear();
            }
            queries.add(ReasonerQueries.atomic(top));
        } else {
            nonResolvableAtoms.add(top);
            if (atoms.isEmpty())
                queries.add(ReasonerQueries.create(nonResolvableAtoms, graph));
        }
    }
    return queries;
}