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:org.apache.tajo.catalog.TypeConverter.java

public static Type convert(TypeDesc type) {
    if (type.getDataType().getType() == TajoDataTypes.Type.RECORD) {
        ImmutableList.Builder<Field> fields = ImmutableList.builder();
        for (Column c : type.getNestedSchema().getRootColumns()) {
            fields.add(FieldConverter.convert(c));
        }//from ww  w .j a va2  s. c om
        return Record(fields.build());
    } else {
        return convert(type.dataType);
    }
}

From source file:org.sonar.plugins.core.issue.ignore.IgnoreIssuesPlugin.java

public static List<?> getExtensions() {
    ImmutableList.Builder<Object> extensions = ImmutableList.builder();

    extensions.addAll(IgnoreIssuesConfiguration.getPropertyDefinitions());
    extensions.add(InclusionPatternInitializer.class, ExclusionPatternInitializer.class, RegexpScanner.class,
            SourceScanner.class, EnforceIssuesFilter.class, IgnoreIssuesFilter.class);

    return extensions.build();
}

From source file:org.basepom.mojo.propertyhelper.StringField.java

public static List<StringField> createStrings(final ValueCache valueCache,
        final StringDefinition[] stringDefinitions) throws IOException {
    checkNotNull(valueCache, "valueCache is null");
    checkNotNull(stringDefinitions, "stringDefinitions is null");

    final ImmutableList.Builder<StringField> result = ImmutableList.builder();

    for (StringDefinition stringDefinition : stringDefinitions) {
        stringDefinition.check();//from   w w  w.  jav a  2  s .c  o m
        final ValueProvider stringValue = valueCache.getValueProvider(stringDefinition);
        final StringField stringField = new StringField(stringDefinition, stringValue);
        result.add(stringField);
    }
    return result.build();
}

From source file:aeon.compiler.context.SqliteContext.java

/**
 * Creates a {@link aeon.compiler.context.SqliteContext} from an instance of {@link aeon.compiler.context.Context}.
 *
 * @param context Source Context for building SqliteContext
 * @return SqliteContext build from Context
 *//* www  .  ja  v a  2s  .  c  o  m*/
@NotNull
public static SqliteContext of(@NotNull final Context context) {
    checkNotNull(context);

    final SqliteEntityName targetClassName = SqliteEntityName
            .fromName(context.getTargetClassName().simpleName());
    final ImmutableList.Builder<SqliteField> builder = ImmutableList.builder();

    for (final Field field : context.getFieldContext().getFields()) {
        builder.add(SqliteField.of(field));
    }

    return new SqliteContext(targetClassName, builder.build());
}

From source file:com.github.richardballard.arbeeutils.stream.MoreCollectors.java

/**
 * Based on code from <a href="https://dzone.com/articles/java-8-collectors-guava">here</a>
 *///from  w  w w  . j a v  a  2  s  . c om
public static @NotNull <T> Collector<T, ?, ImmutableList<T>> toImmutableList() {

    final Supplier<ImmutableList.Builder<T>> supplier = ImmutableList.Builder::new;

    final BiConsumer<ImmutableList.Builder<T>, T> accumulator = ImmutableList.Builder::add;

    final BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build());

    final Function<ImmutableList.Builder<T>, ImmutableList<T>> finisher = ImmutableList.Builder::build;

    return Collector.of(supplier, accumulator, combiner, finisher);
}

From source file:nz.co.fortytwo.signalk.util.TrackSimplifier.java

static List<Position> vertexReduction(List<Position> track, double tolerance) {
    // degenerate case
    if (track.size() < 2) {
        return track;
    }/*from   www .j  av  a2 s . c  o  m*/

    ImmutableList.Builder<Position> result = ImmutableList.builder();
    double tol2 = tolerance * tolerance;

    Position last = track.get(0);
    result.add(last);
    for (int i = 1; i < track.size(); i++) {
        Position current = track.get(i);

        if (distanceSquared(last, current) > tol2) {
            result.add(current);
            last = current;
        }
    }
    return result.build();
}

From source file:cuchaz.m3l.event.handler.ListenerNodeList.java

private synchronized static void addToTracker(ListenerNodeList inst) {
    ImmutableList.Builder<ListenerNodeList> builder = ImmutableList.builder();
    builder.addAll(listTracker);/*from  w w w. j av  a2s. co  m*/
    builder.add(inst);
    listTracker = builder.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  a2s .  c  o m*/
    return new TupleInfo(builder.build());
}

From source file:com.facebook.buck.cxx.Linkers.java

/**
 * Prefixes each of the given linker arguments with "-Xlinker" so that the compiler linker
 * driver will pass these arguments directly down to the linker rather than interpreting them
 * itself./*from w w w.  j a  v a2 s. co  m*/
 *
 * e.g. ["-rpath", "hello/world"] -&gt; ["-Xlinker", "-rpath", "-Xlinker", "hello/world"]
 *
 * Arguments that do not contain commas can instead be passed using the shorter
 * "-Wl,ARGUMENT" form.
 *
 * e.g., ["-rpath", "hello/world"] -&gt; ["-Wl,-rpath", "-Wl,hello/world" ]
 *
 * @param args arguments for the linker.
 * @return arguments to be passed to the compiler linker driver.
 */
public static Iterable<String> iXlinker(Iterable<String> args) {
    ImmutableList.Builder<String> escaped = ImmutableList.builder();
    for (String arg : args) {
        if (arg.contains(",")) {
            escaped.add("-Xlinker");
            escaped.add(arg);
        } else {
            escaped.add("-Wl," + arg);
        }
    }

    return escaped.build();
}

From source file:com.yahoo.yqlplus.engine.internal.plan.types.base.ReflectivePropertyAdapter.java

public static PropertyAdapter create(TypeWidget typeWidget, ProgramValueTypeAdapter adapter,
        TypeLiteral<?> typeLiteral) {
    Map<String, PropertyReader> properties = readProperties(typeLiteral, adapter);
    ImmutableList.Builder<Property> propertyBuilder = ImmutableList.builder();
    for (PropertyReader reader : properties.values()) {
        propertyBuilder.add(reader.property);
    }//  ww w .  j a  v a2s .c  o  m
    List<Property> propertyList = propertyBuilder.build();
    return new ReflectivePropertyAdapter(typeWidget, properties, propertyList);
}