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.generators.type.BaseTypeGenerator.java

/**
 * Converts all Ds3Elements that describe a single xml element into its python code representation.
 * All other Ds3Elements are removed.//from w  w  w.j av  a 2 s.  c  om
 */
protected static ImmutableList<String> toElements(final ImmutableList<Ds3Element> ds3Elements,
        final ImmutableMap<String, Ds3Type> typeMap) {
    if (isEmpty(ds3Elements)) {
        return ImmutableList.of();
    }
    return ds3Elements.stream()
            .filter(ds3Element -> isEmpty(ds3Element.getComponentType())
                    && !isAttribute(ds3Element.getDs3Annotations()))
            .map(element -> toElement(element, typeMap).toPythonCode())
            .collect(GuavaCollectors.immutableList());
}

From source file:com.spectralogic.ds3autogen.python.generators.type.BaseTypeGenerator.java

/**
 * Converts all Ds3Elements that describe a list of xml elements into their python code representation.
 * All other Ds3Elements are removed.//w w w .  java2s  . c o m
 */
protected static ImmutableList<String> toElementLists(final ImmutableList<Ds3Element> ds3Elements,
        final ImmutableMap<String, Ds3Type> typeMap) {
    if (isEmpty(ds3Elements)) {
        return ImmutableList.of();
    }
    return ds3Elements.stream()
            .filter(ds3Element -> hasContent(ds3Element.getComponentType())
                    && !isAttribute(ds3Element.getDs3Annotations()))
            .map(element -> toElementList(element, typeMap).toPythonCode())
            .collect(GuavaCollectors.immutableList());
}

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

/**
 * Converts a list of Ds3Params into a list of Arguments, excluding the Operations param
 *//*from   w  w w.ja  v  a 2s.c  o  m*/
public static ImmutableList<Arguments> getArgsFromParamList(final ImmutableList<Ds3Param> paramList) {
    if (isEmpty(paramList)) {
        return ImmutableList.of();
    }
    return paramList.stream().filter(param -> !param.getName().equals("Operation"))
            .map(RequestConverterUtil::toArgument).collect(GuavaCollectors.immutableList());
}

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

/**
 * Converts all void Ds3Params into a list of Arguments, excluding the Operations param
 *//*  w  ww  . jav a  2  s. c  o  m*/
public static ImmutableList<Arguments> getVoidArgsFromParamList(final ImmutableList<Ds3Param> paramList) {
    if (isEmpty(paramList)) {
        return ImmutableList.of();
    }
    return paramList.stream()
            .filter(param -> !param.getName().equals("Operation") && param.getType().equals("void"))
            .map(RequestConverterUtil::toArgument).collect(GuavaCollectors.immutableList());
}

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

/**
 * Converts all non-void Ds3Params into a list of Arguments, excluding the Operations param
 */// w ww  .jav  a2 s .  c  om
public static ImmutableList<Arguments> getNonVoidArgsFromParamList(final ImmutableList<Ds3Param> paramList) {
    if (isEmpty(paramList)) {
        return ImmutableList.of();
    }
    return paramList.stream()
            .filter(param -> !param.getName().equals("Operation") && !param.getType().equals("void"))
            .map(RequestConverterUtil::toArgument).collect(GuavaCollectors.immutableList());
}

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

/**
 * * Retrieves the fist instance of Ds3ResponseCode with the specified code
 * @throws NoSuchElementException//from   w  ww . j  a va  2 s . c o m
 */
public static Ds3ResponseCode getDs3ResponseCode(final ImmutableList<Ds3ResponseCode> ds3ResponseCodes,
        final int code) {
    if (isEmpty(ds3ResponseCodes)) {
        throw new NoSuchElementException("Ds3ResponseCode list is empty");
    }
    return ds3ResponseCodes.stream().filter(i -> i.getCode() == code).findFirst().get();
}

From source file:com.google.devtools.build.buildjar.javac.BlazeJavacMain.java

private static ImmutableList<FormattedDiagnostic> filterDiagnostics(
        ImmutableList<FormattedDiagnostic> diagnostics) {
    // TODO(cushon): toImmutableList
    ImmutableList.Builder<FormattedDiagnostic> result = ImmutableList.builder();
    diagnostics.stream().filter(d -> !IGNORED_DIAGNOSTIC_CODES.contains(d.getCode())).forEach(result::add);
    return result.build();
}

From source file:com.facebook.buck.jvm.java.JavaPaths.java

/**
 * Processes a list of java source files, extracting and SRC_ZIP or SRC_JAR to the working
 * directory and returns a list of all the resulting .java files.
 *//*from   w  ww. ja  v a2  s  .  c  o m*/
static ImmutableList<Path> extractArchivesAndGetPaths(ProjectFilesystem projectFilesystem,
        ProjectFilesystemFactory projectFilesystemFactory, ImmutableSet<Path> javaSourceFilePaths,
        Path workingDirectory) throws InterruptedException, IOException {

    // Add sources file or sources list to command
    ImmutableList.Builder<Path> sources = ImmutableList.builder();
    for (Path path : javaSourceFilePaths) {
        String pathString = path.toString();
        if (pathString.endsWith(".java")) {
            sources.add(path);
        } else if (pathString.endsWith(SRC_ZIP) || pathString.endsWith(SRC_JAR)) {
            // For a Zip of .java files, create a JavaFileObject for each .java entry.
            ImmutableList<Path> zipPaths = ArchiveFormat.ZIP.getUnarchiver().extractArchive(
                    projectFilesystemFactory, projectFilesystem.resolve(path),
                    projectFilesystem.resolve(workingDirectory), ExistingFileMode.OVERWRITE);
            sources.addAll(zipPaths.stream().filter(input -> input.toString().endsWith(".java")).iterator());
        }
    }
    return sources.build();
}

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

/**
 * Creates the Multi File Delete constructor that uses Iterables
 *///from  w ww.  j a v  a  2 s. c  om
protected static RequestConstructor createIterableConstructor(final ImmutableList<Arguments> constructorArgs,
        final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();

    if (hasContent(constructorArgs)) {
        constructorArgs.stream().filter(arg -> !arg.getName().equalsIgnoreCase("Delete")).forEach(builder::add);
    }

    builder.add(new Arguments("Iterable<Contents>", "Objs"));

    final ImmutableList<String> additionalLines = ImmutableList.of("this.objects = contentsToString(objs);");

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

    return new RequestConstructor(false, additionalLines, builder.build(), constructorArgs, queryParams,
            toConstructorDocs(requestName, argNames, docSpec, 1));
}

From source file:com.spectralogic.ds3autogen.python.PythonCodeGenerator.java

/**
 * Converts all Ds3Requests into the python response handler models
 */// w w w .j a  v a  2 s .co  m
protected static ImmutableList<BaseResponse> toResponseModelList(final ImmutableList<Ds3Request> ds3Requests) {
    if (isEmpty(ds3Requests)) {
        return ImmutableList.of();
    }
    return ds3Requests.stream().map(PythonCodeGenerator::toResponseModel)
            .collect(GuavaCollectors.immutableList());
}