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

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

Introduction

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

Prototype

public static <E> Builder<E> builder() 

Source Link

Usage

From source file:codetoanalyze.java.checkers.Builders.java

@ThreadSafe
public void guavaBuilderOk() {
    ImmutableList.Builder<String> builder = new ImmutableList.Builder();
    builder.add("foo");
    builder.build();//from   w  ww .  j  a  v  a  2s  .co m
}

From source file:org.apache.calcite.interpreter.ProjectNode.java

public ProjectNode(Interpreter interpreter, Project rel) {
    ImmutableList.Builder<Scalar> builder = ImmutableList.builder();
    for (RexNode node : rel.getProjects()) {
        builder.add(interpreter.compile(node));
    }//from   w  w  w  . j a va2  s .c om
    this.projects = builder.build();
    this.source = interpreter.source(rel, 0);
    this.sink = interpreter.sink(rel);
    this.context = interpreter.createContext();
}

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

/**
 * Removes all Spectra Internal requests form a list of Ds3Requests
 *///  www .j  av a 2 s.c o m
protected static ImmutableList<Ds3Request> removeSpectraInternalRequests(
        final ImmutableList<Ds3Request> requests) {
    if (isEmpty(requests)) {
        return ImmutableList.of();
    }
    final ImmutableList.Builder<Ds3Request> builder = ImmutableList.builder();
    for (final Ds3Request request : requests) {
        if (request.getClassification() != Classification.spectrainternal) {
            builder.add(request);
        }
    }
    return builder.build();
}

From source file:ch.ledcom.jpreseed.distro.DistroService.java

public static DistroService create(InputStream configuration) throws URISyntaxException {
    ImmutableList.Builder<Distribution> distributions = ImmutableList.builder();

    Map<String, Map<String, Map<String, String>>> yaml = (Map<String, Map<String, Map<String, String>>>) new Yaml()
            .load(configuration);/*from w  ww .  j a  va 2 s  .c  o m*/

    for (Entry<String, Map<String, Map<String, String>>> distribution : yaml.entrySet()) {
        distributions.add(new Distribution(distribution.getKey(), extractVersions(distribution.getValue())));
    }

    return new DistroService(distributions.build());
}

From source file:org.jclouds.cloudsigma.functions.MapToNICs.java

@Override
public List<NIC> apply(Map<String, String> from) {
    ImmutableList.Builder<NIC> nics = ImmutableList.builder();
    NIC: for (int id : new int[] { 0, 1 }) {
        String key = String.format("nic:%d", id);
        if (!from.containsKey(key + ":model"))
            break NIC;
        NIC.Builder nicBuilder = new NIC.Builder();
        nicBuilder.dhcp(from.get(key + ":dhcp"));
        nicBuilder.model(Model.fromValue(from.get(key + ":model")));
        nicBuilder.vlan(from.get(key + ":vlan"));
        nicBuilder.mac(from.get(key + ":mac"));
        if (from.containsKey(key + ":block"))
            nicBuilder.block(Splitter.on(' ').split(from.get(key + ":block")));
        nics.add(nicBuilder.build());//from   w ww  . j a va 2 s.  co m
    }
    return nics.build();
}

From source file:com.facebook.buck.parcelable.Parser.java

public static ParcelableClass parse(File xml) throws IOException {
    Document doc = XmlDomParser.parse(xml);

    // packageName, className, creatorClass
    Element classElement = (Element) doc.getElementsByTagName("class").item(0);
    String classNameAttr = getAttribute(classElement, "name");
    int splitIndex = classNameAttr.lastIndexOf('.');
    String packageName = classNameAttr.substring(0, splitIndex);
    String className = classNameAttr.substring(splitIndex + 1);
    String creatorClassName = getAttribute(classElement, "creatorClass");

    // imports/*w  ww .j a va 2 s .  c o m*/
    Element importsElement = (Element) doc.getElementsByTagName("imports").item(0);
    String importsText = importsElement.getTextContent();
    Iterable<String> imports = Splitter.on('\n').omitEmptyStrings().trimResults().split(importsText);

    // defaultFieldVisibility
    Element fieldsElement = (Element) doc.getElementsByTagName("fields").item(0);
    String defaultFieldVisibility = getAttribute(fieldsElement, "defaultVisibility");
    if (defaultFieldVisibility == null) {
        defaultFieldVisibility = "private";
    }

    // fields
    ImmutableList.Builder<ParcelableField> fields = ImmutableList.builder();
    NodeList fieldNodes = fieldsElement.getElementsByTagName("field");
    for (int i = 0; i < fieldNodes.getLength(); i++) {
        Element fieldElement = (Element) fieldNodes.item(i);
        ParcelableField field = new ParcelableField(escapeJavaType(getAttribute(fieldElement, "type")),
                getAttribute(fieldElement, "name"), getBooleanAttribute(fieldElement, "mutable"),
                getAttribute(fieldElement, "visibility"), getAttribute(fieldElement, "jsonProperty"),
                getAttribute(fieldElement, "defaultValue"));
        fields.add(field);
    }

    return new ParcelableClass(packageName, imports, className,
            creatorClassName == null ? className : creatorClassName, defaultFieldVisibility, fields.build(),
            getAttribute(classElement, "extends"), getAttribute(classElement, "superParams"));
}

From source file:com.google.devtools.build.xcode.xcodegen.testing.PbxTypes.java

/**
 * Extracts the list of PBX references {@code phase} depends on through
 * {@link PBXFrameworksBuildPhase#getFiles()}.
 *///from  w ww.j a  v a2 s  .c o  m
public static ImmutableList<PBXReference> pbxFileReferences(PBXFrameworksBuildPhase phase) {
    ImmutableList.Builder<PBXReference> phaseFileReferences = ImmutableList.builder();
    for (PBXBuildFile buildFile : phase.getFiles()) {
        phaseFileReferences.add(buildFile.getFileRef());
    }
    return phaseFileReferences.build();
}

From source file:com.facebook.buck.features.filebundler.CopyingFileBundler.java

@Override
protected void addCopySteps(ProjectFilesystem filesystem,
        BuildCellRelativePathFactory buildCellRelativePathFactory, ImmutableList.Builder<Step> steps,
        Path relativePath, Path absolutePath, Path destination) {
    if (destination.getParent() != null) {
        steps.add(MkdirStep.of(buildCellRelativePathFactory.from(destination.getParent())));
    }//from  ww w .ja  va  2s  .  com
    steps.add(CopyStep.forFile(filesystem, absolutePath, destination));
}

From source file:ru.codeinside.gses.activiti.forms.values.ValueBuilder.java

List<PropertyValue<?>> toCollection() {
    ImmutableList.Builder<PropertyValue<?>> builder = ImmutableList.builder();
    for (ValueBuilder valueBuilderObject : valueBuilders) {
        PropertyValue<?> propertyValue = valueBuilderObject.toPropertyValue();
        builder.add(propertyValue);/*from w w  w.  ja va 2s.c  o  m*/
    }
    return builder.build();
}

From source file:com.google.errorprone.bugpatterns.testdata.BadImportPositiveCases.java

public void variableDeclarationsNestedGenerics() {
    Builder<Builder<String>> builder1;
    Builder<Builder> builder1Raw;//from  w  w w  .jav a  2s.  c  om
    ImmutableList.Builder<Builder<String>> builder2;
    ImmutableList.Builder<Builder> builder2Raw;
}