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:com.google.devtools.build.lib.rules.AliasProvider.java

public static AliasProvider fromAliasRule(Label label, ConfiguredTarget actual) {
    ImmutableList.Builder<Label> chain = ImmutableList.builder();
    chain.add(label);//from   w  w w  .j av  a2s. c  o  m
    AliasProvider dep = actual.getProvider(AliasProvider.class);
    if (dep != null) {
        chain.addAll(dep.getAliasChain());
    }

    return new AliasProvider(chain.build());
}

From source file:org.gradle.model.internal.type.TypeWrapper.java

void collectClasses(ImmutableList.Builder<Class<?>> builder);

From source file:eu.arthepsy.sonar.plugins.scapegoat.ScapegoatConfiguration.java

public static List<PropertyDefinition> getPropertyDefinitions() {
    ImmutableList.Builder<PropertyDefinition> properties = ImmutableList.builder();
    properties.add(PropertyDefinition.builder(REPORT_PATH_PROPERTY_KEY).category(CATEGORY)
            .subCategory(SUBCATEGORY).index(0).name("Scapegoat report path")
            .description("Path to generated scapegoat xml report.").type(PropertyType.STRING)
            .defaultValue("target/scapegoat-report/scapegoat.xml").build());
    return properties.build();
}

From source file:blue.lapis.common.command.impl.Parsing.java

public static ImmutableList<String> split(String s, String delimiter) {
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    int tokenEnd = s.indexOf(delimiter);
    int loc = 0;/*  www  .  j  av  a  2  s . c  o m*/
    while (tokenEnd >= 0) {
        if (tokenEnd > loc) {
            builder.add(s.substring(loc, tokenEnd));
        }
        loc = tokenEnd + delimiter.length();
        tokenEnd = s.indexOf(delimiter, loc);
    }
    if (loc < s.length())
        builder.add(s.substring(loc, s.length()));

    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());
    }/* www  . j a v a 2  s  .c  o  m*/
    return builder.build();
}

From source file:com.android.ide.common.res2.DuplicateDataException.java

static <I extends DataItem> Message[] createMessages(@NonNull Collection<Collection<I>> duplicateDataItemSets) {
    List<Message> messages = Lists.newArrayListWithCapacity(duplicateDataItemSets.size());
    for (Collection<I> duplicateItems : duplicateDataItemSets) {
        ImmutableList.Builder<SourceFilePosition> positions = ImmutableList.builder();
        for (I item : duplicateItems) {
            if (!item.isRemoved()) {
                positions.add(getPosition(item));
            }/*  w  w  w  .  j  a  v  a2  s.  co  m*/
        }
        messages.add(
                new Message(Message.Kind.ERROR, DUPLICATE_RESOURCES, DUPLICATE_RESOURCES, positions.build()));
    }
    return Iterables.toArray(messages, Message.class);
}

From source file:com.facebook.buck.util.MoreCollectors.java

/**
 * Returns a {@code Collector} that builds an {@code ImmutableList}.
 *
 * This {@code Collector} behaves similar to
 * {@code Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf)} but without
 * building the intermediate list./*from   w ww  .  jav a 2  s  .c  o  m*/
 *
 * @param <T> the type of the input elements
 * @return a {@code Collector} that builds an {@code ImmutableList}.
 */
public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() {
    return Collector.<T, ImmutableList.Builder<T>, ImmutableList<T>>of(ImmutableList::builder,
            ImmutableList.Builder::add, (left, right) -> left.addAll(right.build()),
            ImmutableList.Builder::build);
}

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

/**
 * Combine, in order, several {@link NativeLinkableInput} objects into a single one.
 *//*from   w w  w.ja  va2 s  .  co  m*/
public static NativeLinkableInput concat(Iterable<NativeLinkableInput> items) {
    ImmutableList.Builder<SourcePath> inputs = ImmutableList.builder();
    ImmutableList.Builder<String> args = ImmutableList.builder();

    for (NativeLinkableInput item : items) {
        inputs.addAll(item.getInputs());
        args.addAll(item.getArgs());
    }

    return new NativeLinkableInput(inputs.build(), args.build());
}

From source file:dagger.internal.codegen.Compilers.java

/**
 * Returns a compiler that runs the Dagger and {@code @AutoAnnotation} processors, along with
 * extras./*from www  . j  a v a 2s .  c om*/
 */
static Compiler daggerCompiler(Processor... extraProcessors) {
    ImmutableList.Builder<Processor> processors = ImmutableList.builder();
    processors.add(new ComponentProcessor(), new AutoAnnotationProcessor());
    processors.add(extraProcessors);
    return javac().withProcessors(processors.build());
}

From source file:com.tyler.collectors.GuavaCollectors.java

public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() {

    return Collector.of(ImmutableList.Builder<T>::new, ImmutableList.Builder<T>::add,
            (l, r) -> l.addAll(r.build()), ImmutableList.Builder<T>::build);
}