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.presto.cost.StatsCalculatorModule.java

@Provides
@Singleton/* ww  w  .  j  a va 2 s .  co  m*/
public static StatsCalculator createNewStatsCalculator(Metadata metadata) {
    StatsNormalizer normalizer = new StatsNormalizer();
    ScalarStatsCalculator scalarStatsCalculator = new ScalarStatsCalculator(metadata);
    FilterStatsCalculator filterStatsCalculator = new FilterStatsCalculator(metadata, scalarStatsCalculator,
            normalizer);

    ImmutableList.Builder<ComposableStatsCalculator.Rule<?>> rules = ImmutableList.builder();
    rules.add(new OutputStatsRule());
    rules.add(new TableScanStatsRule(metadata, normalizer));
    rules.add(new SimpleFilterProjectSemiJoinStatsRule(normalizer, filterStatsCalculator)); // this must be before FilterStatsRule
    rules.add(new FilterStatsRule(normalizer, filterStatsCalculator));
    rules.add(new ValuesStatsRule(metadata));
    rules.add(new LimitStatsRule(normalizer));
    rules.add(new EnforceSingleRowStatsRule(normalizer));
    rules.add(new ProjectStatsRule(scalarStatsCalculator, normalizer));
    rules.add(new ExchangeStatsRule(normalizer));
    rules.add(new JoinStatsRule(filterStatsCalculator, normalizer));
    rules.add(new SpatialJoinStatsRule(filterStatsCalculator, normalizer));
    rules.add(new AggregationStatsRule(normalizer));
    rules.add(new UnionStatsRule(normalizer));
    rules.add(new AssignUniqueIdStatsRule());
    rules.add(new SemiJoinStatsRule());
    rules.add(new RowNumberStatsRule(normalizer));

    return new ComposableStatsCalculator(rules.build());
}

From source file:com.github.steveash.jg2p.seq.TokenWindow.java

public static ImmutableList<TokenWindow> makeTokenWindowsForInts(int[] neighbors) {
    ImmutableList.Builder<TokenWindow> builder = ImmutableList.builder();
    for (int i = 0; i < neighbors.length; i++) {
        builder.add(new TokenWindow(neighbors[i], 1));
    }//  ww w .ja  v  a2 s .c o m
    return builder.build();
}

From source file:com.facebook.buck.ocaml.OcamlDescriptionEnhancer.java

public static ImmutableList<StringWithMacrosArg> toStringWithMacrosArgs(BuildTarget target,
        CellPathResolver cellPathResolver, BuildRuleResolver resolver, Iterable<StringWithMacros> flags) {
    ImmutableList.Builder<StringWithMacrosArg> args = ImmutableList.builder();
    for (StringWithMacros flag : flags) {
        args.add(StringWithMacrosArg.of(flag,
                ImmutableList.of(new LocationMacroExpander(), new ExecutableMacroExpander()), target,
                cellPathResolver, resolver));
    }/*www.j  av a 2  s  .  c  om*/
    return args.build();
}

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

/**
 * Converts each item in {@code pathStrings} using {@link #fromString(FileSystem, String)}.
 *//*from   w w w  .  ja  v a  2  s  .com*/
static List<Path> fromStrings(FileSystem fileSystem, Iterable<String> pathStrings) {
    ImmutableList.Builder<Path> result = new ImmutableList.Builder<>();
    for (String pathString : pathStrings) {
        result.add(fromString(fileSystem, pathString));
    }
    return result.build();
}

From source file:com.google.devtools.build.lib.rules.objc.SdkFramework.java

/**
 * Returns an iterable which contains the name of each given framework in the same order.
 *//* w ww  .j  av a2s .c om*/
static Iterable<String> names(Iterable<SdkFramework> frameworks) {
    ImmutableList.Builder<String> result = new ImmutableList.Builder<>();
    for (SdkFramework framework : frameworks) {
        result.add(framework.getName());
    }
    return result.build();
}

From source file:com.facebook.presto.serde.TupleInfoSerde.java

public static TupleInfo readTupleInfo(SliceInput sliceInput) {
    checkNotNull(sliceInput, "sliceInput is null");

    int fieldCount = sliceInput.readUnsignedByte();
    ImmutableList.Builder<TupleInfo.Type> builder = ImmutableList.builder();
    for (int i = 0; i < fieldCount; i++) {
        builder.add(TupleInfo.Type.values()[sliceInput.readUnsignedByte()]);
    }//from  w  w  w  .  j  a  v a  2 s.  c o  m
    return new TupleInfo(builder.build());
}

From source file:com.facebook.presto.execution.StageInfo.java

private static void addAllStages(StageInfo stageInfo, ImmutableList.Builder<StageInfo> collector) {
    collector.add(stageInfo);
    for (StageInfo subStage : stageInfo.getSubStages()) {
        addAllStages(subStage, collector);
    }/* w w  w.  java 2  s  . c om*/
}

From source file:com.spectralogic.ds3autogen.testutil.Ds3ResponseCodeFixture.java

/**
 * Creates a list of populated response codes for testing purposes. If hasPayload is true,
 * then one of the response types will be non-null. Else, both non-error response types
 * will have a type of "null"/*from   ww w. j  a  v  a  2  s  .co  m*/
 */
public static ImmutableList<Ds3ResponseCode> createTestResponseCodes(final boolean hasPayload) {
    final ImmutableList.Builder<Ds3ResponseCode> builder = ImmutableList.builder();

    if (hasPayload) {
        builder.add(new Ds3ResponseCode(200, ImmutableList
                .of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobWithChunksApiBean", null))));
    } else {
        builder.add(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("null", null))));
    }

    builder.add(new Ds3ResponseCode(204, ImmutableList.of(new Ds3ResponseType("null", null))));

    builder.add(new Ds3ResponseCode(404, ImmutableList
            .of(new Ds3ResponseType("com.spectralogic.s3.server.domain.HttpErrorResultApiBean", null))));

    return builder.build();
}

From source file:com.facebook.presto.block.uncompressed.UncompressedTupleInfoSerde.java

public static TupleInfo deserialize(SliceInput sliceInput) {
    checkNotNull(sliceInput, "slice is null");

    int fieldCount = sliceInput.readUnsignedByte();
    ImmutableList.Builder<TupleInfo.Type> builder = ImmutableList.builder();
    for (int i = 0; i < fieldCount; i++) {
        builder.add(TupleInfo.Type.values()[sliceInput.readUnsignedByte()]);
    }//from  ww  w .ja  va  2s.  c o m
    return new TupleInfo(builder.build());
}

From source file:org.kairosdb.testing.BeanValidationHelper.java

public static List<String> messagesFor(Collection<? extends ConstraintViolation<?>> violations) {
    ImmutableList.Builder<String> messages = new ImmutableList.Builder<String>();
    for (ConstraintViolation<?> violation : violations) {
        messages.add(violation.getPropertyPath().toString() + " " + violation.getMessage());
    }/*w  ww .j  a  va 2  s .co m*/

    return messages.build();
}