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:msi.gama.lang.gaml.validation.GamlModelBuilder.java

private static ModelDescription buildModelDescription(final URI uri, final List<GamlCompilationError> errors) {
    try {/* ww w.  j  a v  a2  s . com*/
        final GamlResource r = (GamlResource) buildResourceSet.getResource(uri, true);
        // Syntactic errors detected, we cannot build the resource
        if (r.hasErrors()) {
            if (errors != null)
                errors.add(new GamlCompilationError("Syntax errors ", IGamlIssue.GENERAL,
                        r.getContents().get(0), false, false));
            return null;
        } else {
            // We build the description
            final ModelDescription model = r.buildCompleteDescription();
            if (model != null)
                model.validate();
            if (errors != null)
                Iterables.addAll(errors, r.getValidationContext());
            return model;
        }
    } finally {
        final boolean wasDeliver = buildResourceSet.eDeliver();
        try {
            buildResourceSet.eSetDeliver(false);
            buildResourceSet.getResources().clear();
        } finally {
            buildResourceSet.eSetDeliver(wasDeliver);
        }
    }
}

From source file:com.zimbra.soap.mail.type.AttachmentsInfo.java

public void setAttachments(Iterable<AttachSpec> attachments) {
    this.attachments.clear();
    if (attachments != null) {
        Iterables.addAll(this.attachments, attachments);
    }//from w w  w . ja v a2s  .  c om
}

From source file:com.zimbra.soap.admin.type.AdminAttrsImpl.java

@Override
public void setAttrs(Iterable<Attr> attrs) {
    this.attrs.clear();
    if (attrs != null) {
        Iterables.addAll(this.attrs, attrs);
    }//from  w  w w. j a  v a 2  s. c  om
}

From source file:vogar.android.DeviceDalvikVm.java

@Override
public VmCommandBuilder newVmCommandBuilder(Action action, File workingDirectory) {
    List<String> vmCommand = new ArrayList<String>();
    vmCommand.addAll(run.target.targetProcessPrefix(workingDirectory));
    vmCommand.add(run.getAndroidData());
    Iterables.addAll(vmCommand, run.invokeWith());
    vmCommand.add("dalvikvm");

    // If you edit this, see also HostDalvikVm...
    VmCommandBuilder vmCommandBuilder = new VmCommandBuilder(run.log).vmCommand(vmCommand)
            .vmArgs("-Duser.home=" + run.deviceUserHome).vmArgs("-Duser.name=" + run.target.getDeviceUserName())
            .vmArgs("-Duser.language=en").vmArgs("-Duser.region=US").maxLength(1024);
    if (!run.benchmark) {
        vmCommandBuilder.vmArgs("-Xverify:none");
        vmCommandBuilder.vmArgs("-Xdexopt:none");
        vmCommandBuilder.vmArgs("-Xcheck:jni");
    }/*from   www.j a  va  2 s  .  c o m*/
    // dalvikvm defaults to no limit, but the framework sets the limit at 2000.
    vmCommandBuilder.vmArgs("-Xjnigreflimit:2000");
    return vmCommandBuilder;
}

From source file:com.kixeye.chassis.transport.swagger.CustomModelPropertiesProvider.java

@Override
public Iterable<? extends ModelProperty> propertiesForSerialization(ResolvedType type) {
    List<ModelProperty> serializableProperties = newArrayList();
    Iterables.addAll(serializableProperties, defaultModelPropertiesProvider.propertiesForSerialization(type));
    if (type.isInstanceOf(scala.Product.class)) {
        //special case for Scala Case Classes.  fields are defined in the constructor
        addConstructors(serializableProperties, type);
    }/*  w w  w . jav a  2  s .c o m*/
    return serializableProperties;
}

From source file:com.zimbra.soap.mail.type.ModifyContactSpec.java

public void setAttrs(Iterable<ModifyContactAttr> attrs) {
    this.attrs.clear();
    if (attrs != null) {
        Iterables.addAll(this.attrs, attrs);
    }// w w  w. j a  v a  2s  .  co m
}

From source file:com.zimbra.soap.admin.type.MailboxVolumesInfo.java

public void setVolumes(Iterable<MailboxVolumeInfo> volumes) {
    this.volumes.clear();
    if (volumes != null) {
        Iterables.addAll(this.volumes, volumes);
    }//from   w w  w.j  a  v  a 2 s. c  o m
}

From source file:org.apache.mahout.knn.means.ThreadedKmeans.java

public Searcher cluster(final DistanceMeasure distance, List<Iterable<MatrixSlice>> data, final int maxClusters,
        final int threads, final StreamingKmeans.CentroidFactory centroidFactory)
        throws InterruptedException, ExecutionException {
    // initialize scale
    int i = 0;/*from   w  w  w . j  av a  2 s. c o  m*/
    final int width = data.get(0).iterator().next().vector().size();
    Matrix sample = new DenseMatrix(100, width);
    for (Iterable<MatrixSlice> split : data) {
        sample = sampleRows(sample, i, Iterables.limit(split, 1000), 100);
        i += 100;
    }

    List<Callable<Searcher>> tasks = Lists.newArrayList();
    ExecutorService pool = Executors.newFixedThreadPool(threads);
    for (final Iterable<MatrixSlice> split : data) {
        tasks.add(new Callable<Searcher>() {
            @Override
            public Searcher call() {
                return new StreamingKmeans().cluster(split, maxClusters, centroidFactory);
            }
        });
    }
    List<Future<Searcher>> results = pool.invokeAll(tasks);
    pool.shutdown();

    List<MatrixSlice> raw = Lists.newArrayList();
    for (Future<Searcher> result : results) {
        Iterables.addAll(raw, result.get());
    }

    return new StreamingKmeans().cluster(raw, data.size() * maxClusters, centroidFactory);
}

From source file:org.apache.druid.segment.indexing.granularity.UniformGranularitySpec.java

@JsonCreator
public UniformGranularitySpec(@JsonProperty("segmentGranularity") Granularity segmentGranularity,
        @JsonProperty("queryGranularity") Granularity queryGranularity, @JsonProperty("rollup") Boolean rollup,
        @JsonProperty("intervals") List<Interval> inputIntervals) {
    this.queryGranularity = queryGranularity == null ? DEFAULT_QUERY_GRANULARITY : queryGranularity;
    this.rollup = rollup == null ? Boolean.TRUE : rollup;
    this.segmentGranularity = segmentGranularity == null ? DEFAULT_SEGMENT_GRANULARITY : segmentGranularity;

    if (inputIntervals != null) {
        List<Interval> granularIntervals = Lists.newArrayList();
        for (Interval inputInterval : inputIntervals) {
            Iterables.addAll(granularIntervals, this.segmentGranularity.getIterable(inputInterval));
        }/*from  ww  w. j  a v a  2s .  c  om*/
        this.inputIntervals = ImmutableList.copyOf(inputIntervals);
        this.wrappedSpec = new ArbitraryGranularitySpec(queryGranularity, rollup, granularIntervals);
    } else {
        this.inputIntervals = null;
        this.wrappedSpec = null;
    }
}

From source file:org.graylog2.grok.MongoDbGrokPatternService.java

@Override
public Set<GrokPattern> loadAll() {
    final DBCursor<GrokPattern> grokPatterns = dbCollection.find();
    final Set<GrokPattern> patterns = Sets.newHashSet();
    Iterables.addAll(patterns, grokPatterns);
    return patterns;
}