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.facebook.buck.java.JavacOptionsUtil.java

/**
 * Adds the appropriate options for javac given the specified {@link com.facebook.buck.step.ExecutionContext}.
 *//*from   w  ww  .  ja va 2 s.  c  o m*/
static void addOptions(ImmutableList.Builder<String> optionsBuilder, ExecutionContext context,
        File outputDirectory, Set<String> classpathEntries, Supplier<String> bootclasspathSupplier,
        AnnotationProcessingData annotationProcessingData, String sourceLevel, String targetLevel) {
    Preconditions.checkNotNull(optionsBuilder);
    Preconditions.checkNotNull(context);
    Preconditions.checkNotNull(outputDirectory);
    Preconditions.checkNotNull(classpathEntries);
    Preconditions.checkNotNull(bootclasspathSupplier);
    Preconditions.checkNotNull(annotationProcessingData);
    Preconditions.checkNotNull(sourceLevel);
    Preconditions.checkNotNull(targetLevel);

    // verbose flag, if appropriate.
    if (context.getVerbosity().shouldUseVerbosityFlagIfAvailable()) {
        optionsBuilder.add("-verbose");
    }

    // Add some standard options.
    optionsBuilder.add("-target", sourceLevel);
    optionsBuilder.add("-source", targetLevel);

    // Include all debug information. Let Proguard be responsible for stripping it from production
    // builds.
    optionsBuilder.add("-g");

    // Specify the output directory.
    optionsBuilder.add("-d").add(outputDirectory.getAbsolutePath());

    // Override the bootclasspath if Buck is building Java code for Android.
    String bootclasspath = bootclasspathSupplier.get();
    if (bootclasspath != null) {
        optionsBuilder.add("-bootclasspath", bootclasspath);
    }

    // Build up and set the classpath.
    if (!classpathEntries.isEmpty()) {
        String classpath = Joiner.on(":").join(classpathEntries);
        optionsBuilder.add("-classpath", classpath);
    }

    // Add annotation processors.
    if (!annotationProcessingData.isEmpty()) {

        // Specify where to generate sources so IntelliJ can pick them up.
        String generateTo = annotationProcessingData.getGeneratedSourceFolderName();
        if (generateTo != null) {
            optionsBuilder.add("-s").add(generateTo);
        }

        // Specify processorpath to search for processors.
        optionsBuilder.add("-processorpath",
                Joiner.on(':').join(annotationProcessingData.getSearchPathElements()));

        // Specify names of processors.
        if (!annotationProcessingData.getNames().isEmpty()) {
            optionsBuilder.add("-processor", Joiner.on(',').join(annotationProcessingData.getNames()));
        }

        // Add processor parameters.
        for (String parameter : annotationProcessingData.getParameters()) {
            optionsBuilder.add("-A" + parameter);
        }

        if (annotationProcessingData.getProcessOnly()) {
            optionsBuilder.add("-proc:only");
        }
    }
}

From source file:org.sonar.java.JavaClasspathProperties.java

public static List<PropertyDefinition> getProperties() {
    ImmutableList.Builder<PropertyDefinition> extensions = ImmutableList.builder();
    extensions.add(PropertyDefinition.builder(SONAR_JAVA_BINARIES).description(
            "Comma-separated paths to directories containing the binary files (directories with class files).")
            .hidden().build());//from   w  w w . j a  va2s  .co m
    extensions.add(PropertyDefinition.builder(SONAR_JAVA_LIBRARIES)
            .description("Comma-separated paths to libraries required by the project.").hidden().build());
    extensions.add(PropertyDefinition.builder(SONAR_JAVA_TEST_BINARIES).description(
            "Comma-separated paths to directories containing the binary files (directories with class files).")
            .hidden().build());
    extensions.add(PropertyDefinition.builder(SONAR_JAVA_TEST_LIBRARIES)
            .description("Comma-separated paths to libraries required by the project.").hidden().build());
    return extensions.build();
}

From source file:org.terasology.math.geom.Polygon.java

/**
 * @param vertices a list of vertices (vertices are copied)
 *///from w ww. j  a va2  s .c om
public static Polygon createCopy(List<Vector2f> vertices) {
    Builder<ImmutableVector2f> bldr = ImmutableList.builder();
    for (BaseVector2f v : vertices) {
        bldr.add(new ImmutableVector2f(v));
    }

    return new Polygon(bldr.build());
}

From source file:com.android.builder.core.BootClasspathBuilder.java

@NonNull
public static ImmutableList<File> computeFullBootClasspath(@NonNull IAndroidTarget target,
        @NonNull File annotationsJar) {
    Preconditions.checkNotNull(target);//  ww w .j  av  a2s  . c om
    Preconditions.checkNotNull(annotationsJar);

    ImmutableList.Builder<File> classpath = ImmutableList.builder();

    for (String p : target.getBootClasspath()) {
        classpath.add(new File(p));
    }

    // add additional libraries if any
    List<IAndroidTarget.OptionalLibrary> libs = target.getAdditionalLibraries();
    for (IAndroidTarget.OptionalLibrary lib : libs) {
        File jar = lib.getJar();
        Verify.verify(jar != null, "Jar missing from additional library %s.", lib.getName());
        classpath.add(jar);
    }

    // add optional libraries if any
    List<IAndroidTarget.OptionalLibrary> optionalLibraries = target.getOptionalLibraries();
    for (IAndroidTarget.OptionalLibrary lib : optionalLibraries) {
        File jar = lib.getJar();
        Verify.verify(jar != null, "Jar missing from optional library %s.", lib.getName());
        classpath.add(jar);
    }

    // add annotations.jar if needed.
    if (target.getVersion().getApiLevel() <= 15) {
        classpath.add(annotationsJar);
    }

    return classpath.build();
}

From source file:com.lambdautils.util.stream.MoreCollectors.java

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

From source file:eu.arthepsy.sonar.plugins.elixir.ElixirConfiguration.java

public static List<PropertyDefinition> getPropertyDefinitions() {
    ImmutableList.Builder<PropertyDefinition> properties = ImmutableList.builder();
    return properties.build();
}

From source file:com.publictransitanalytics.scoregenerator.schedule.patching.Appending.java

public static List<VehicleEvent> appendToSchedule(final List<VehicleEvent> schedule,
        final List<RouteSequenceItem> extension) {
    final LocalDateTime baseTime = schedule.get(schedule.size() - 1).getScheduledTime();
    final ImmutableList.Builder<VehicleEvent> builder = ImmutableList.builder();
    builder.addAll(schedule);//from  ww  w .  j av a2s  .c om
    LocalDateTime lastTime = baseTime;
    for (final RouteSequenceItem item : extension) {
        final LocalDateTime newTime = lastTime.plus(item.getDelta());
        builder.add(new VehicleEvent(item.getStop(), newTime));
        lastTime = newTime;
    }
    return builder.build();
}

From source file:org.apache.james.javax.MultipartUtil.java

public static List<BodyPart> retrieveBodyParts(Multipart multipart) throws MessagingException {
    ImmutableList.Builder<BodyPart> builder = ImmutableList.builder();
    for (int i = 0; i < multipart.getCount(); i++) {
        builder.add(multipart.getBodyPart(i));
    }/*from  ww w. j  a v  a  2  s. c  om*/
    return builder.build();
}

From source file:com.google.idea.blaze.base.run.testlogs.BlazeTestXmlFinderStrategy.java

/**
 * Attempt to find all output test XML files associated with the given run configuration. Called
 * after the 'blaze test' process completes.
 *//*from   w ww . j av  a2  s .com*/
static ImmutableList<CompletedTestTarget> locateTestXmlFiles(Project project) {
    BuildSystem buildSystem = Blaze.getBuildSystem(project);
    ImmutableList.Builder<CompletedTestTarget> output = ImmutableList.builder();
    for (BlazeTestXmlFinderStrategy strategy : EP_NAME.getExtensions()) {
        if (strategy.handlesBuildSystem(buildSystem)) {
            output.addAll(strategy.findTestXmlFiles(project));
        }
    }
    return output.build();
}

From source file:com.palantir.typescript.services.language.ScriptElementModifierKind.java

public static ImmutableList<ScriptElementModifierKind> parseList(String kindModifiers) {
    ImmutableList.Builder<ScriptElementModifierKind> kindModifiersBuilder = ImmutableList.builder();

    if (kindModifiers.length() > 0) {
        for (String kindModifier : Splitter.on(',').split(kindModifiers)) {
            kindModifiersBuilder.add(fromString(kindModifier));
        }//from  w  ww  . j  av a2  s .c  o m
    }

    return kindModifiersBuilder.build();
}