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:org.jclouds.vcloud.domain.internal.VmImpl.java

public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp,
        @Nullable String description, Iterable<Task> tasks, @Nullable VCloudVirtualHardwareSection hardware,
        @Nullable VCloudOperatingSystemSection os, @Nullable NetworkConnectionSection networkConnectionSection,
        @Nullable GuestCustomizationSection guestCustomization, @Nullable String vAppScopedLocalId) {
    super(name, type, id);
    this.status = status;
    this.vApp = vApp;// TODO: once <1.0 is killed check not null
    this.description = description;
    Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
    this.hardware = hardware;
    this.os = os;
    this.networkConnectionSection = networkConnectionSection;
    this.guestCustomization = guestCustomization;
    this.vAppScopedLocalId = vAppScopedLocalId;
}

From source file:com.zimbra.soap.mail.message.ApplyFilterRulesRequest.java

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

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

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

From source file:eu.interedition.text.xml.ConverterBuilder.java

public ConverterBuilder listener(Iterable<ConverterListener> listeners) {
    Iterables.addAll(this.listeners, listeners);
    return this;
}

From source file:com.google.devtools.build.lib.runtime.BlazeCommandUtils.java

/**
 * Returns the set of all options (including those inherited directly and
 * transitively) for this AbstractCommand's @Command annotation.
 *
 * <p>Why does metaprogramming always seem like such a bright idea in the
 * beginning?/*  w  w  w  .  j av  a2  s.  c  o m*/
 */
public static ImmutableList<Class<? extends OptionsBase>> getOptions(Class<? extends BlazeCommand> clazz,
        Iterable<BlazeModule> modules, ConfiguredRuleClassProvider ruleClassProvider) {
    Command commandAnnotation = clazz.getAnnotation(Command.class);
    if (commandAnnotation == null) {
        throw new IllegalStateException("@Command missing for " + clazz.getName());
    }

    Set<Class<? extends OptionsBase>> options = new HashSet<>();
    options.addAll(getCommonOptions(modules));
    Collections.addAll(options, commandAnnotation.options());

    if (commandAnnotation.usesConfigurationOptions()) {
        options.addAll(ruleClassProvider.getConfigurationOptions());
    }

    for (BlazeModule blazeModule : modules) {
        Iterables.addAll(options, blazeModule.getCommandOptions(commandAnnotation));
    }

    for (Class<? extends BlazeCommand> base : commandAnnotation.inherits()) {
        options.addAll(getOptions(base, modules, ruleClassProvider));
    }
    return ImmutableList.copyOf(options);
}

From source file:org.apache.beam.runners.flink.translation.functions.HashingFlinkCombineRunner.java

@Override
public void combine(FlinkCombiner<K, InputT, AccumT, OutputT> flinkCombiner,
        WindowingStrategy<Object, W> windowingStrategy, SideInputReader sideInputReader,
        PipelineOptions options, Iterable<WindowedValue<KV<K, InputT>>> elements,
        Collector<WindowedValue<KV<K, OutputT>>> out) throws Exception {

    @SuppressWarnings("unchecked")
    TimestampCombiner timestampCombiner = windowingStrategy.getTimestampCombiner();
    WindowFn<Object, W> windowFn = windowingStrategy.getWindowFn();

    // Flink Iterable can be iterated over only once.
    List<WindowedValue<KV<K, InputT>>> inputs = new ArrayList<>();
    Iterables.addAll(inputs, elements);

    Set<W> windows = collectWindows(inputs);
    Map<W, W> windowToMergeResult = mergeWindows(windowingStrategy, windows);

    // Combine all windowedValues into map
    Map<W, Tuple2<AccumT, Instant>> mapState = new HashMap<>();
    Iterator<WindowedValue<KV<K, InputT>>> iterator = inputs.iterator();
    WindowedValue<KV<K, InputT>> currentValue = iterator.next();
    K key = currentValue.getValue().getKey();
    do {/*ww  w.j ava2s . c o m*/
        for (BoundedWindow w : currentValue.getWindows()) {
            @SuppressWarnings("unchecked")
            W currentWindow = (W) w;
            W mergedWindow = windowToMergeResult.get(currentWindow);
            mergedWindow = mergedWindow == null ? currentWindow : mergedWindow;
            Set<W> singletonW = Collections.singleton(mergedWindow);
            Tuple2<AccumT, Instant> accumAndInstant = mapState.get(mergedWindow);
            if (accumAndInstant == null) {
                AccumT accumT = flinkCombiner.firstInput(key, currentValue.getValue().getValue(), options,
                        sideInputReader, singletonW);
                Instant windowTimestamp = timestampCombiner.assign(mergedWindow,
                        windowFn.getOutputTime(currentValue.getTimestamp(), mergedWindow));
                accumAndInstant = new Tuple2<>(accumT, windowTimestamp);
                mapState.put(mergedWindow, accumAndInstant);
            } else {
                accumAndInstant.f0 = flinkCombiner.addInput(key, accumAndInstant.f0,
                        currentValue.getValue().getValue(), options, sideInputReader, singletonW);
                accumAndInstant.f1 = timestampCombiner.combine(accumAndInstant.f1,
                        timestampCombiner.assign(mergedWindow, windowingStrategy.getWindowFn()
                                .getOutputTime(currentValue.getTimestamp(), mergedWindow)));
            }
        }
        if (iterator.hasNext()) {
            currentValue = iterator.next();
        } else {
            break;
        }
    } while (true);

    // Output the final value of combiners
    for (Map.Entry<W, Tuple2<AccumT, Instant>> entry : mapState.entrySet()) {
        AccumT accumulator = entry.getValue().f0;
        Instant windowTimestamp = entry.getValue().f1;
        out.collect(WindowedValue.of(
                KV.of(key,
                        flinkCombiner.extractOutput(key, accumulator, options, sideInputReader,
                                Collections.singleton(entry.getKey()))),
                windowTimestamp, entry.getKey(), PaneInfo.NO_FIRING));
    }

}

From source file:eu.interedition.collatex.neo4j.Neo4jVariantGraph.java

@Override
public Set<Transposition> transpositions() {
    final Set<Transposition> transpositions = Sets.newHashSet();
    for (Vertex v : vertices()) {
        Iterables.addAll(transpositions, v.transpositions());
    }// w w  w .  ja  v a2 s  .c o m
    return transpositions;
}

From source file:com.mycila.ujd.mbean.JmxAnalyzer.java

private <T> Iterable<String> sort(Iterable<T> it) {
    Set<String> sorted = new TreeSet<String>();
    Iterables.addAll(sorted, Iterables.transform(it, Functions.toStringFunction()));
    return sorted;
}

From source file:com.zimbra.soap.account.message.GetSMIMEPublicCertsRequest.java

public void setEmails(Iterable<String> emails) {
    this.emails.clear();
    if (emails != null) {
        Iterables.addAll(this.emails, emails);
    }//w ww.jav a 2s .c om
}

From source file:org.amanzi.awe.statistics.dto.impl.StatisticsRow.java

/**
 * @param statisticsCells The statisticsCells to set.
 *///from  w ww.  j  av a 2 s  .c o  m
public void setStatisticsCells(final Iterable<IStatisticsCell> statisticsCells) {
    // TODO KV: make sure about this way solution
    this.statisticsCells.clear();
    Iterables.addAll(this.statisticsCells, statisticsCells);
}