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:io.prestosql.benchmark.driver.PrestoBenchmarkDriver.java

private static List<BenchmarkQuery> readQueries(File queriesDir) throws IOException {
    File[] files = queriesDir.listFiles();
    if (files == null) {
        return ImmutableList.of();
    }/*  w ww  .  ja  va 2s.c  o  m*/
    Arrays.sort(files);

    ImmutableList.Builder<BenchmarkQuery> queries = ImmutableList.builder();
    for (File file : files) {
        String fileName = file.getName();
        if (fileName.endsWith(".sql")) {
            queries.add(new BenchmarkQuery(file));
        }
    }
    return queries.build();
}

From source file:com.facebook.buck.jvm.java.JavaPaths.java

/**
 * Processes a list of java source files, extracting and SRC_ZIP or SRC_JAR to the working
 * directory and returns a list of all the resulting .java files.
 */// w  w  w .  j a  v a 2s . c om
static ImmutableList<Path> extractArchivesAndGetPaths(ProjectFilesystem projectFilesystem,
        ProjectFilesystemFactory projectFilesystemFactory, ImmutableSet<Path> javaSourceFilePaths,
        Path workingDirectory) throws InterruptedException, IOException {

    // Add sources file or sources list to command
    ImmutableList.Builder<Path> sources = ImmutableList.builder();
    for (Path path : javaSourceFilePaths) {
        String pathString = path.toString();
        if (pathString.endsWith(".java")) {
            sources.add(path);
        } else if (pathString.endsWith(SRC_ZIP) || pathString.endsWith(SRC_JAR)) {
            // For a Zip of .java files, create a JavaFileObject for each .java entry.
            ImmutableList<Path> zipPaths = ArchiveFormat.ZIP.getUnarchiver().extractArchive(
                    projectFilesystemFactory, projectFilesystem.resolve(path),
                    projectFilesystem.resolve(workingDirectory), ExistingFileMode.OVERWRITE);
            sources.addAll(zipPaths.stream().filter(input -> input.toString().endsWith(".java")).iterator());
        }
    }
    return sources.build();
}

From source file:com.noodlewiz.xjavab.ext.record.internal.ReplyUnpacker.java

public static EnableContextReply unpackEnableContext(final ByteBuffer __xjb_buf) {
    __xjb_buf.position(4);/* www . jav a 2  s .  co m*/
    final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    __xjb_buf.position(1);
    final short category = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUByte(__xjb_buf);
    __xjb_buf.position(8);
    final short elementHeader = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUByte(__xjb_buf);
    final boolean clientSwapped = com.noodlewiz.xjavab.core.internal.Unpacker.unpackBool(__xjb_buf);
    com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 2);
    final long xidBase = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    final long serverTime = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    final long recSequenceNum = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 8);
    final com.google.common.collect.ImmutableList.Builder<Byte> __xjb_dataBuilder = new com.google.common.collect.ImmutableList.Builder<Byte>();
    for (int __xjb_i = 0; (__xjb_i < (length * 4)); __xjb_i++) {
        __xjb_dataBuilder.add(com.noodlewiz.xjavab.core.internal.Unpacker.unpackByte(__xjb_buf));
    }
    final List<Byte> data = __xjb_dataBuilder.build();
    return new EnableContextReply(category, elementHeader, clientSwapped, xidBase, serverTime, recSequenceNum,
            data);
}

From source file:eu.eubrazilcc.lvl.core.conf.ConfigurationFinder.java

private static ImmutableList<File> convertPathListToFiles(final String baseDir, final String[] filenames) {
    final ImmutableList.Builder<File> builder = new ImmutableList.Builder<File>();
    for (final String filename : filenames) {
        builder.add(new File(concat(baseDir, filename)));
    }/* ww w.j a  va 2 s  .c o m*/
    return builder.build();
}

From source file:com.google.devtools.bazel.e4b.Activator.java

/**
 * List targets configure for <code>project</code>. Each project configured for Bazel is
 * configured to track certain targets and this function fetch this list from the project
 * preferences.//from w  ww.j a  va 2s .  c o m
 */
public static ImmutableList<String> getTargets(IProject project) throws BackingStoreException {
    // Get the list of targets from the preferences
    IScopeContext projectScope = new ProjectScope(project);
    Preferences projectNode = projectScope.getNode(PLUGIN_ID);
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (String s : projectNode.keys()) {
        if (s.startsWith("target")) {
            builder.add(projectNode.get(s, ""));
        }
    }
    return builder.build();
}

From source file:com.facebook.presto.server.PluginDiscovery.java

private static List<String> classInterfaces(String name, ClassLoader classLoader) {
    ImmutableList.Builder<String> list = ImmutableList.builder();
    ClassReader reader = readClass(name, classLoader);
    for (String binaryName : reader.getInterfaces()) {
        list.add(javaName(binaryName));
    }//ww w. ja  va 2s . c  o m
    if (reader.getSuperName() != null) {
        list.addAll(classInterfaces(javaName(reader.getSuperName()), classLoader));
    }
    return list.build();
}

From source file:com.facebook.buck.jvm.java.JavaLibraryRules.java

static void addAccumulateClassNamesStep(JavaLibrary javaLibrary, BuildableContext buildableContext,
        ImmutableList.Builder<Step> steps) {

    Path pathToClassHashes = JavaLibraryRules.getPathToClassHashes(javaLibrary.getBuildTarget(),
            javaLibrary.getProjectFilesystem());
    steps.add(new MkdirStep(javaLibrary.getProjectFilesystem(), pathToClassHashes.getParent()));
    steps.add(new AccumulateClassNamesStep(javaLibrary.getProjectFilesystem(),
            Optional.ofNullable(javaLibrary.getPathToOutput()), pathToClassHashes));
    buildableContext.recordArtifact(pathToClassHashes);
}

From source file:org.apache.beam.sdk.values.RowType.java

private static RowType fromFields(List<Field> fields) {
    ImmutableList.Builder<String> names = ImmutableList.builder();
    ImmutableList.Builder<Coder> coders = ImmutableList.builder();

    for (Field field : fields) {
        names.add(field.name());
        coders.add(field.coder());//from w ww  . ja  v  a2s.c  o m
    }

    return fromNamesAndCoders(names.build(), coders.build());
}

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

static <T> ImmutableList<ImmutableList<T>> createEmptySchedule(int numVehicles) {
    final ImmutableList.Builder<ImmutableList<T>> builder = ImmutableList.builder();
    for (int i = 0; i < numVehicles; i++) {
        builder.add(ImmutableList.<T>of());
    }/*from  w w w  .j  a  v a 2  s .  com*/
    return builder.build();
}

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

public static List<String> commonLinkAndCompileFlagsForClang(ObjcProvider provider,
        ObjcConfiguration configuration) {
    ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
    if (Platform.forArch(configuration.getIosCpu()) == Platform.SIMULATOR) {
        builder.add("-mios-simulator-version-min=" + configuration.getMinimumOs());
    } else {//from   w ww. j a v a 2 s .  c o  m
        builder.add("-miphoneos-version-min=" + configuration.getMinimumOs());
    }

    if (configuration.generateDebugSymbols()) {
        builder.add("-g");
    }

    return builder.add("-arch", configuration.getIosCpu()).add("-isysroot", sdkDir(configuration))
            // TODO(bazel-team): Pass framework search paths to Xcodegen.
            .add("-F", sdkDir(configuration) + "/Developer/Library/Frameworks")
            // As of sdk8.1, XCTest is in a base Framework dir
            .add("-F", frameworkDir(configuration))
            // Add custom (non-SDK) framework search paths. For each framework foo/bar.framework,
            // include "foo" as a search path.
            .addAll(Interspersing.beforeEach("-F",
                    PathFragment.safePathStrings(uniqueParentDirectories(provider.get(FRAMEWORK_DIR)))))
            .build();
}