Example usage for com.google.common.collect ImmutableList.Builder add

List of usage examples for com.google.common.collect ImmutableList.Builder add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:com.facebook.buck.rules.args.AbstractSourcePathArg.java

public static ImmutableList<Arg> from(Iterable<SourcePath> paths) {
    ImmutableList.Builder<Arg> converted = ImmutableList.builder();
    for (SourcePath path : paths) {
        converted.add(SourcePathArg.of(path));
    }//from  www.ja  v a2s  .c  om
    return converted.build();
}

From source file:com.google.caliper.XmlUtils.java

public static ImmutableList<Node> childrenOf(Node node) {
    NodeList children = node.getChildNodes();
    ImmutableList.Builder<Node> result = ImmutableList.builder();
    for (int i = 0, size = children.getLength(); i < size; i++) {
        result.add(children.item(i));
    }/*from  ww  w.  j  ava  2 s. c o  m*/
    return result.build();
}

From source file:com.outerspacecat.cassandra.Cassandra.java

/**
 * Creates a list of mutations based on {@code columns}.
 * /*from   w ww  . j a  va  2  s.  c  o m*/
 * @param columns the columns to update. Must be non {@code null}, all
 *        elements must be non {@code null}, may be empty.
 * @return a list of mutations. Never {@code null}.
 */
public static ImmutableList<Mutation> mutations(final Column... columns) {
    Preconditions.checkNotNull(columns, "columns required");
    for (Column column : columns)
        Preconditions.checkNotNull(column, "all columns must be non null");

    ImmutableList.Builder<Mutation> b = ImmutableList.builder();
    for (Column c : columns)
        b.add(new Mutation().setColumn_or_supercolumn(new ColumnOrSuperColumn().setColumn(c)));
    return b.build();
}

From source file:org.gradle.buildinit.plugins.internal.modifiers.BuildInitDsl.java

public static List<String> listSupported() {
    ImmutableList.Builder<String> supported = ImmutableList.builder();
    for (BuildInitDsl dsl : values()) {
        supported.add(dsl.getId());
    }// w w  w . j a  va 2 s  . co m
    return supported.build();
}

From source file:com.stackframe.regex.RegularExpressions.java

/**
 * Compile an Iterable of regular expressions.
 *
 * @param expressions an Iterable of Strings representing regular expressions
 * @return an Iterable of compiled Pattern objects
 *//*from w w w  .j av a2 s . c  o  m*/
public static Iterable<Pattern> compile(Iterable<String> expressions) {
    ImmutableList.Builder<Pattern> b = ImmutableList.builder();
    for (String expression : expressions) {
        b.add(Pattern.compile(expression));
    }

    return b.build();
}

From source file:org.sonar.plugins.xml.checks.CheckRepository.java

public static List<Class> getCheckClasses() {
    ImmutableList.Builder<Class> builder = ImmutableList.builder();

    for (AbstractXmlCheck check : getChecks()) {
        builder.add(check.getClass());
    }/*from ww  w. j  a va  2  s . co  m*/

    return builder.build();
}

From source file:org.gradle.internal.scripts.ScriptingLanguages.java

private static ImmutableList<String> extensionsOf(List<ScriptingLanguage> scriptingLanguages) {
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (ScriptingLanguage language : scriptingLanguages) {
        builder.add(language.getExtension());
    }/*from   w w w  .  ja  v a 2  s . c  o  m*/
    return builder.build();
}

From source file:com.facebook.presto.operator.scalar.ListLiteralCast.java

@ScalarOperator(OperatorType.CAST)
@SqlType(ListLiteralType.NAME)//from  w w w.  ja  v  a 2s .c o m
public static List<Integer> castArrayToListLiteral(@SqlType("array(integer)") Block array) {
    ImmutableList.Builder<Integer> listBuilder = ImmutableList.builder();
    for (int i = 0; i < array.getPositionCount(); i++) {
        listBuilder.add(array.getInt(i, 0));
    }

    return listBuilder.build();
}

From source file:com.google.devtools.build.docgen.skylark.SkylarkDocUtils.java

/**
 * Returns a list of parameter documentation elements for a given method doc and the method's
 * parameters./*from  w  w w .  jav a 2 s . c o m*/
 */
static ImmutableList<SkylarkParamDoc> determineParams(SkylarkMethodDoc methodDoc, Param[] userSuppliedParams,
        Param extraPositionals, Param extraKeywords) {
    ImmutableList.Builder<SkylarkParamDoc> paramsBuilder = ImmutableList.builder();
    for (Param param : userSuppliedParams) {
        paramsBuilder.add(new SkylarkParamDoc(methodDoc, param));
    }
    if (!extraPositionals.name().isEmpty()) {
        paramsBuilder.add(new SkylarkParamDoc(methodDoc, extraPositionals));
    }
    if (!extraKeywords.name().isEmpty()) {
        paramsBuilder.add(new SkylarkParamDoc(methodDoc, extraKeywords));
    }
    return paramsBuilder.build();
}

From source file:net.minecraftforge.fml.common.CertificateHelper.java

public static ImmutableList<String> getFingerprints(Certificate[] certificates) {
    int len = 0;/*from  w  ww  .  ja v  a 2s  .  c om*/
    if (certificates != null) {
        len = certificates.length;
    }
    ImmutableList.Builder<String> certBuilder = ImmutableList.builder();
    for (int i = 0; i < len; i++) {
        certBuilder.add(CertificateHelper.getFingerprint(certificates[i]));
    }
    return certBuilder.build();
}