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:org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventTableColumns.java

/**
 * Get the event table columns for a given trace definition
 *
 * @param definition The {@link CustomTraceDefinition} of the trace for which you want the columns
 * @return The set of columns for the given trace.
 *//*  www. java  2  s  .c o  m*/
public static Collection<CustomEventTableColumn> generateColumns(CustomTraceDefinition definition) {
    ImmutableList.Builder<CustomEventTableColumn> builder = new ImmutableList.Builder<>();
    List<OutputColumn> outputs = definition.outputs;
    for (int i = 0; i < outputs.size(); i++) {
        String name = outputs.get(i).name;
        if (name != null) {
            builder.add(new CustomEventTableColumn(name, i));
        }
    }
    return builder.build();
}

From source file:com.spectralogic.ds3autogen.Ds3SpecConverter.java

/**
 * Converts the contract names of all response code types and component
 * types to the SDK naming scheme, as defined within the NameMapper
 *//* w  w  w  .  j  a  va2 s.c o m*/
protected static ImmutableList<Ds3ResponseCode> convertAllResponseCodes(
        final ImmutableList<Ds3ResponseCode> responseCodes, final NameMapper nameMapper) {
    if (isEmpty(responseCodes)) {
        return responseCodes;
    }
    final ImmutableList.Builder<Ds3ResponseCode> builder = ImmutableList.builder();
    for (final Ds3ResponseCode responseCode : responseCodes) {
        builder.add(convertResponseCode(responseCode, nameMapper));
    }
    return builder.build();
}

From source file:com.facebook.presto.tpch.TpchIndexedData.java

private static <E extends TpchEntity> RecordSet getRecordSet(TpchTable<E> table, double scaleFactor,
        List<String> columnNames) {
    ImmutableList.Builder<TpchColumn<E>> builder = ImmutableList.builder();
    for (String columnName : columnNames) {
        builder.add(table.getColumn(columnName));
    }/*from w  ww  .  jav  a 2 s  .c  om*/
    return createTpchRecordSet(table, builder.build(), scaleFactor, 1, 1);
}

From source file:com.github.rinde.logistics.pdptw.solver.CheapestInsertionHeuristic.java

static ImmutableList<ImmutableList<Parcel>> createSchedule(GlobalStateObject state) {
    final ImmutableList.Builder<ImmutableList<Parcel>> b = ImmutableList.builder();
    for (final VehicleStateObject vso : state.getVehicles()) {
        if (vso.getRoute().isPresent()) {
            b.add(vso.getRoute().get());
        } else {/*from   w w w .  j  a  v a  2  s. c  om*/
            b.add(ImmutableList.<Parcel>of());
        }
    }
    return b.build();
}

From source file:com.google.devtools.build.android.resources.IntArrayFieldInitializer.java

public static FieldInitializer of(String name, String value) {
    Preconditions.checkArgument(value.startsWith("{ "), "Expected list starting with { ");
    Preconditions.checkArgument(value.endsWith(" }"), "Expected list ending with } ");
    // Check for an empty list, which is "{ }".
    if (value.length() < 4) {
        return new IntArrayFieldInitializer(name, ImmutableList.<Integer>of());
    }/*from w w  w  .ja va 2 s .  c om*/
    ImmutableList.Builder<Integer> intValues = ImmutableList.builder();
    String trimmedValue = value.substring(2, value.length() - 2);
    Iterable<String> valueStrings = Splitter.on(',').trimResults().split(trimmedValue);
    for (String valueString : valueStrings) {
        intValues.add(Integer.decode(valueString));
    }
    return new IntArrayFieldInitializer(name, intValues.build());
}

From source file:io.prestosql.sql.testing.TreeAssertions.java

private static List<Node> linearizeTree(Node tree) {
    ImmutableList.Builder<Node> nodes = ImmutableList.builder();
    new DefaultTraversalVisitor<Node, Void>() {
        @Override//from   w ww.  jav a  2  s  . co m
        public Node process(Node node, @Nullable Void context) {
            Node result = super.process(node, context);
            nodes.add(node);
            return result;
        }
    }.process(tree, null);
    return nodes.build();
}

From source file:com.facebook.presto.ml.ModelUtils.java

public static List<Model> deserializeModels(byte[] bytes) {
    Slice slice = Slices.wrappedBuffer(bytes);
    int numModels = slice.getInt(0);

    int offset = SIZE_OF_INT + SIZE_OF_INT * numModels;
    ImmutableList.Builder<Model> models = ImmutableList.builder();
    for (int i = 0; i < numModels; i++) {
        int length = slice.getInt(SIZE_OF_INT * (i + 1));
        models.add(deserialize(slice.getBytes(offset, length)));
        offset += length;//w  w w .  j a  v a 2 s .c  o m
    }

    return models.build();
}

From source file:org.gradle.api.internal.artifacts.transform.DefaultTransformInfoFactory.java

private static List<UserCodeBackedTransformer> unpackTransformerChain(ArtifactTransformer transformer) {
    final ImmutableList.Builder<UserCodeBackedTransformer> builder = ImmutableList.builder();
    transformer.visitLeafTransformers(new Action<ArtifactTransformer>() {
        @Override//w  ww.ja  va2 s.  c o m
        public void execute(ArtifactTransformer transformer) {
            builder.add((UserCodeBackedTransformer) transformer);
        }
    });
    return builder.build();
}

From source file:org.sonar.java.checks.InvalidDateValuesCheck.java

private static List<MethodMatcher> dateGetMatchers() {
    ImmutableList.Builder<MethodMatcher> builder = ImmutableList.builder();
    for (String dateGetMethod : DATE_GET_METHODS) {
        builder.add(dateMethodInvocationMatcherGetter(JAVA_UTIL_DATE, dateGetMethod));
        builder.add(dateMethodInvocationMatcherGetter(JAVA_SQL_DATE, dateGetMethod));
    }//  ww  w .  j  a  va2s . c  o  m
    return builder.build();
}

From source file:org.gradle.api.internal.artifacts.transform.DefaultTransformationNodeFactory.java

private static List<TransformationStep> unpackTransformation(Transformation transformation) {
    final ImmutableList.Builder<TransformationStep> builder = ImmutableList.builder();
    transformation.visitTransformationSteps(new Action<TransformationStep>() {
        @Override/* w w w .j  a v a2  s  . co m*/
        public void execute(TransformationStep transformation) {
            builder.add(transformation);
        }
    });
    return builder.build();
}