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.ds3autogen.python.helpers.PythonHelper.java

/**
 * Creates a comma separated list of constructor parameters which always starts with 'self'
 *///  w  w  w . j a  v  a  2s.  c o  m
public static String toRequestInitList(final ImmutableList<String> strings) {
    if (isEmpty(strings)) {
        return "self";
    }
    return "self, " + strings.stream().collect(Collectors.joining(", "));
}

From source file:com.spectralogic.ds3autogen.java.utils.CommonRequestGeneratorUtils.java

/**
 * Converts a list of arguments into a list of query params
 *//*from   www .  j a  v  a2s .  c  o m*/
public static ImmutableList<QueryParam> argsToQueryParams(final ImmutableList<Arguments> args) {
    if (isEmpty(args)) {
        return ImmutableList.of();
    }
    return args.stream().map(QueryParam::new).collect(GuavaCollectors.immutableList());
}

From source file:com.facebook.buck.features.go.CgoLibraryDescription.java

private static ImmutableList<StringWithMacros> wrapFlags(ImmutableList<String> flags) {
    return flags.stream().map(flag -> StringWithMacros.of(ImmutableList.of(Either.ofLeft(flag))))
            .collect(ImmutableList.toImmutableList());
}

From source file:com.spectralogic.ds3autogen.python.helpers.PythonHelper.java

/**
 * Creates comma separated lines for a list of strings. This is used to
 * generate the lists within the python model descriptors.
 *///from   w  w  w .ja v  a 2  s . c  o m
public static String toCommaSeparatedLines(final ImmutableList<String> lines, final int depth) {
    if (isEmpty(lines)) {
        return "";
    }
    return "\n" + pythonIndent(depth) + lines.stream().collect(Collectors.joining(",\n" + pythonIndent(depth)))
            + "\n" + pythonIndent(depth - 1);
}

From source file:com.spectralogic.ds3autogen.java.generators.requestmodels.CreateObjectRequestGenerator.java

/**
 * Creates the create deprecated object request constructor that
 * uses the Channel parameter//from  w  ww  . ja v  a  2  s.  co  m
 */
protected static RequestConstructor createDeprecatedConstructor(final ImmutableList<Arguments> constructorArgs,
        final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(constructorArgs);
    builder.add(new Arguments("SeekableByteChannel", "Channel"));

    final ImmutableList<String> additionalLines = ImmutableList
            .of("this.stream = new SeekableByteChannelInputStream(channel);");

    final ImmutableList<Arguments> updatedArgs = builder.build();
    final ImmutableList<String> argNames = updatedArgs.stream().map(Arguments::getName)
            .collect(GuavaCollectors.immutableList());

    return new RequestConstructor(true, additionalLines, updatedArgs, updatedArgs, ImmutableList.of(),
            toConstructorDocs(requestName, argNames, docSpec, 1));
}

From source file:org.apache.james.jmap.methods.SetFilterMethod.java

private static String format(ImmutableList<Rule.Id> ids) {
    return "["
            + ids.stream().map(Rule.Id::asString).map(SetFilterMethod::quote).collect(Collectors.joining(","))
            + "]";
}

From source file:com.spectralogic.dsbrowser.gui.services.ds3Panel.DeleteService.java

private static ImmutableList<String> getBuckets(final ImmutableList<TreeItem<Ds3TreeTableValue>> values) {
    return values.stream().map(TreeItem::getValue).map(Ds3TreeTableValue::getBucketName).distinct()
            .collect(GuavaCollectors.immutableList());
}

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

public static String getEnumValues(final ImmutableList<String> enumValues) {
    if (isEmpty(enumValues)) {
        return "";
    }//from   w  ww  .  ja  v  a 2 s  .c om
    return enumValues.stream().map(value -> indent(1) + value).collect(Collectors.joining(",\n"));
}

From source file:com.google.template.soy.soytree.TemplateElementNodeBuilder.java

/**
 * Check for duplicate header variable names and append error text for each duplicate to the
 * `errorReporter`. For example, this is an error:
 *
 * <pre>{@code/*from   w w w  . jav  a  2  s  . c  o  m*/
 * {@param s: bool}
 * {@state s: bool}
 * }</pre>
 *
 * Note that it is not possible to have duplicate names of the same declaration type. Any
 * duplicate {@code @state} or {@code @param} will have been flagged as error during the resolve-
 * names pass or in {@link #addParams(Iterable)}.
 */
@VisibleForTesting
static void checkDuplicateHeaderVars(ImmutableList<? extends TemplateHeaderVarDefn> params,
        ImmutableList<? extends TemplateHeaderVarDefn> stateVars, ErrorReporter errorReporter) {

    final Set<String> stateVarNames = stateVars.stream().map(TemplateHeaderVarDefn::name)
            .collect(toImmutableSet());

    Iterable<? extends TemplateHeaderVarDefn> duplicateVars = Iterables.filter(params,
            param -> stateVarNames.contains(param.name()));
    for (TemplateHeaderVarDefn duplicateVar : duplicateVars) {
        errorReporter.report(duplicateVar.nameLocation(), DUPLICATE_DECLARATION, duplicateVar.name());
    }
}

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

/**
 * Find all response types of all requests
 *///ww w  . j a  v  a  2s.c om
public static ImmutableSet<String> getResponseTypes(final ImmutableList<Request> allRequests) {
    return allRequests.stream().map(Request::getResponseType).collect(GuavaCollectors.immutableSet());
}