Example usage for com.google.common.collect Iterables addAll

List of usage examples for com.google.common.collect Iterables addAll

Introduction

In this page you can find the example usage for com.google.common.collect Iterables addAll.

Prototype

public static <T> boolean addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd) 

Source Link

Document

Adds all elements in iterable to collection .

Usage

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

public static Resources fromTargetControls(FileSystem fileSystem, PBXBuildFiles pbxBuildFiles,
        Iterable<TargetControl> targetControls) {
    ImmutableSetMultimap.Builder<TargetControl, PBXBuildFile> buildFiles = new ImmutableSetMultimap.Builder<>();

    for (TargetControl targetControl : targetControls) {
        List<PBXBuildFile> targetBuildFiles = new ArrayList<>();

        Iterable<String> simpleImports = Iterables.concat(targetControl.getXcassetsDirList(),
                targetControl.getBundleImportList());
        // Add .bundle, .xcassets directories to the Project Navigator so they are visible from within
        // Xcode.
        // Bundle imports are handled very similarly to asset catalogs, so we just add them with the
        // same logic. Xcode's automatic file type detection logic is smart enough to see it is a
        // bundle and link it properly, and add the {@code lastKnownFileType} property.
        for (String simpleImport : simpleImports) {
            targetBuildFiles.add(pbxBuildFiles.getStandalone(FileReference.of(simpleImport, SourceTree.GROUP)));
        }//from   w ww  .j a v  a  2s.c om

        Iterables.addAll(targetBuildFiles, pbxBuildFiles.get(AggregateReferenceType.PBXVariantGroup,
                RelativePaths.fromStrings(fileSystem, targetControl.getGeneralResourceFileList())));

        // If this target is a binary, save the build files. Otherwise, we don't need them. The file
        // references we generated with fileObjects will be added to the main group later.
        if (!Equaling.of(ProductType.STATIC_LIBRARY, XcodeprojGeneration.productType(targetControl))) {
            buildFiles.putAll(targetControl, targetBuildFiles);
        }
    }

    return new Resources(buildFiles.build());
}

From source file:com.torodb.torod.db.backends.query.processors.ProcessorTestUtils.java

private static HashSet<QueryCriteriaWrapper> convertQueryCriteria(Set<QueryCriteria> queries) {
    HashSet<QueryCriteriaWrapper> result = Sets.newHashSetWithExpectedSize(queries.size());

    Iterables.addAll(result, Iterables.transform(queries, new Function<QueryCriteria, QueryCriteriaWrapper>() {

        @Override//from   w w  w .  j  av a2s . c o  m
        public QueryCriteriaWrapper apply(QueryCriteria input) {
            return new QueryCriteriaWrapper(input);
        }
    }));

    return result;
}

From source file:co.cask.cdap.internal.app.runtime.batch.distributed.MapReduceContainerHelper.java

/**
 * Returns a list of path to be used for the MapReduce framework classpath.
 *
 * @param hConf the configuration for the job.
 * @param result a list for appending MR framework classpath
 * @return the same {@code result} list from the argument
 *///from ww  w  .j  a  v a  2s.c om
public static List<String> getMapReduceClassPath(Configuration hConf, List<String> result) {
    String framework = hConf.get(MRJobConfig.MAPREDUCE_APPLICATION_FRAMEWORK_PATH);

    // For classpath config get from the hConf, we splits it with both "," and ":" because one can set
    // the conf with something like "path1,path2:path3" and
    // it should become "path1:path2:path3" in the target JVM process
    Splitter splitter = Splitter.on(Pattern.compile(",|" + File.pathSeparatorChar)).trimResults()
            .omitEmptyStrings();

    // If MR framework is non specified, use yarn.application.classpath and mapreduce.application.classpath
    // Otherwise, only use the mapreduce.application.classpath
    if (framework == null) {
        String yarnClassPath = hConf.get(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
                Joiner.on(",").join(YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH));
        Iterables.addAll(result, splitter.split(yarnClassPath));
    }

    // Add MR application classpath
    Iterables.addAll(result, splitter.split(hConf.get(MRJobConfig.MAPREDUCE_APPLICATION_CLASSPATH,
            MRJobConfig.DEFAULT_MAPREDUCE_APPLICATION_CLASSPATH)));
    return result;
}

From source file:co.cask.cdap.etl.batch.ETLBatchTestBase.java

protected List<GenericRecord> readOutput(TimePartitionedFileSet fileSet, Schema schema) throws IOException {
    org.apache.avro.Schema avroSchema = new org.apache.avro.Schema.Parser().parse(schema.toString());
    DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(avroSchema);
    List<GenericRecord> records = Lists.newArrayList();
    for (Location dayLoc : fileSet.getEmbeddedFileSet().getBaseLocation().list()) {
        // this level should be the day (ex: 2015-01-19)
        for (Location timeLoc : dayLoc.list()) {
            // this level should be the time (ex: 21-23.1234567890000)
            for (Location file : timeLoc.list()) {
                // this level should be the actual mapred output
                String locName = file.getName();

                if (locName.endsWith(".avro")) {
                    DataFileStream<GenericRecord> fileStream = new DataFileStream<>(file.getInputStream(),
                            datumReader);
                    Iterables.addAll(records, fileStream);
                    fileStream.close();// www  . j  a  va2 s .co  m
                }
            }
        }
    }
    return records;
}

From source file:com.google.devtools.build.lib.rules.android.AndroidAaptActionHelper.java

/**
 * Returns the artifacts needed as inputs to process the resources/assets.
 *//*  ww w  .j  av  a  2 s  .  c  o  m*/
private Iterable<Artifact> getInputs() {
    if (inputs.isEmpty()) {
        inputs.add(AndroidSdkProvider.fromRuleContext(ruleContext).getAndroidJar());
        inputs.add(manifest);
        Iterables.addAll(inputs, Iterables.concat(
                Iterables.transform(resourceContainers, new Function<ResourceContainer, Iterable<Artifact>>() {
                    @Override
                    public Iterable<Artifact> apply(ResourceContainer container) {
                        return container.getArtifacts();
                    }
                })));
    }
    return inputs;
}

From source file:vogar.android.HostDalvikVm.java

@Override
public VmCommandBuilder newVmCommandBuilder(Action action, File workingDirectory) {
    String buildRoot = System.getenv("ANDROID_BUILD_TOP");

    List<File> jars = new ArrayList<File>();
    for (String jar : AndroidSdk.HOST_BOOTCLASSPATH) {
        jars.add(new File(buildRoot, "out/host/linux-x86/framework/" + jar + ".jar"));
    }//w w w .j  a  v a  2s .co m
    Classpath bootClasspath = Classpath.of(jars);

    VmCommandBuilder builder = new VmCommandBuilder(run.log).userDir(workingDirectory)
            .env("ANDROID_PRINTF_LOG", "tag").env("ANDROID_LOG_TAGS", "*:i")
            .env("ANDROID_DATA", dalvikCache().getParent());

    List<String> vmCommand = new ArrayList<String>();
    Iterables.addAll(vmCommand, run.invokeWith());

    vmCommand.add(buildRoot + "/out/host/linux-x86/bin/dalvikvm");
    builder.env("ANDROID_ROOT", buildRoot + "/out/host/linux-x86")
            .env("LD_LIBRARY_PATH", buildRoot + "/out/host/linux-x86/lib")
            .env("DYLD_LIBRARY_PATH", buildRoot + "/out/host/linux-x86/lib");

    // If you edit this, see also DeviceDalvikVm...
    builder.vmCommand(vmCommand).vmArgs("-Xbootclasspath:" + bootClasspath.toString())
            .vmArgs("-Duser.language=en").vmArgs("-Duser.region=US");
    if (!run.benchmark) {
        builder.vmArgs("-Xverify:none");
        builder.vmArgs("-Xdexopt:none");
        builder.vmArgs("-Xcheck:jni");
    }
    // dalvikvm defaults to no limit, but the framework sets the limit at 2000.
    builder.vmArgs("-Xjnigreflimit:2000");
    return builder;
}

From source file:org.apache.drill.exec.schema.ListSchema.java

@Override
public Iterable<? extends Field> removeUnreadFields() {
    final List<Field> removedFields = Lists.newArrayList();
    Iterables.removeIf(fields, new Predicate<Field>() {
        @Override//from  w w w. j  av a2s. c  o m
        public boolean apply(Field field) {
            if (!field.isRead()) {
                removedFields.add(field);
                return true;
            } else if (field.hasSchema()) {
                Iterables.addAll(removedFields, field.getAssignedSchema().removeUnreadFields());
            }

            return false;
        }
    });
    return removedFields;
}

From source file:com.zimbra.soap.voice.message.GetVoiceInfoResponse.java

public void setVoiceInfoForPhones(Iterable<VoiceInfo> voiceInfoForPhones) {
    this.voiceInfoForPhones.clear();
    if (voiceInfoForPhones != null) {
        Iterables.addAll(this.voiceInfoForPhones, voiceInfoForPhones);
    }/*w w w.  j  a va  2 s  .  c  om*/
}

From source file:org.sfs.nodes.VolumeReplicaGroup.java

public VolumeReplicaGroup setExcludeVolumeIds(Iterable<String> volumeIds) {
    if (excludeVolumes != null) {
        excludeVolumes.clear();/*w  ww . j  a  v  a2  s.c om*/
    } else {
        excludeVolumes = new HashSet<>();
    }
    Iterables.addAll(excludeVolumes, volumeIds);
    return this;
}

From source file:com.zimbra.soap.admin.message.GetClusterStatusResponse.java

public void setServices(Iterable<ClusterServiceInfo> services) {
    this.services.clear();
    if (services != null) {
        Iterables.addAll(this.services, services);
    }/*from  w ww . ja  v a 2  s. c  o  m*/
}