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:blackboard.plugin.hayabusa.controller.ProviderRestController.java

@RequestMapping(value = "commands", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)//from  w ww  . j a va2 s  .c  om
public @ResponseBody CommandResponse getCommands() {
    List<Provider> providers = _providerService.getProviders();
    List<Iterable<Command>> commands = Lists.newArrayList();
    for (Provider provider : providers) {
        commands.add(provider.getCommands());
    }

    CommandList commandList = new CommandList();
    Iterables.addAll(commandList, Iterables.concat(commands));
    return new CommandResponse(commandList);
}

From source file:com.google.gerrit.server.git.ScanningChangeCacheImpl.java

public static List<Change> scan(Repository repo, ReviewDb db) throws OrmException, IOException {
    Map<String, Ref> refs = repo.getRefDatabase().getRefs(RefNames.REFS_CHANGES);
    Set<Change.Id> ids = new LinkedHashSet<>();
    for (Ref r : refs.values()) {
        Change.Id id = Change.Id.fromRef(r.getName());
        if (id != null) {
            ids.add(id);//from w w w  .  j a v a2  s . co m
        }
    }
    List<Change> changes = new ArrayList<>(ids.size());
    // A batch size of N may overload get(Iterable), so use something smaller,
    // but still >1.
    for (List<Change.Id> batch : Iterables.partition(ids, 30)) {
        Iterables.addAll(changes, db.changes().get(batch));
    }
    return changes;
}

From source file:org.gradle.model.internal.manage.schema.extract.DefaultModelSchemaExtractor.java

@Override
public <T> ModelSchema<T> extract(ModelType<T> type, ModelSchemaCache cache) {
    DefaultModelSchemaExtractionContext<T> context = DefaultModelSchemaExtractionContext.root(type);
    List<DefaultModelSchemaExtractionContext<?>> validations = Lists.newArrayList();
    Queue<DefaultModelSchemaExtractionContext<?>> unsatisfiedDependencies = new ArrayDeque<DefaultModelSchemaExtractionContext<?>>();
    DefaultModelSchemaExtractionContext<?> extractionContext = context;
    validations.add(extractionContext);/*  w  ww.jav  a 2  s . c  o  m*/

    while (extractionContext != null) {
        extractSchema(extractionContext, cache);
        Iterable<DefaultModelSchemaExtractionContext<?>> dependencies = extractionContext.getChildren();
        Iterables.addAll(validations, dependencies);
        pushUnsatisfiedDependencies(dependencies, unsatisfiedDependencies, cache);
        extractionContext = unsatisfiedDependencies.poll();
    }

    for (DefaultModelSchemaExtractionContext<?> validationContext : Lists.reverse(validations)) {
        // TODO - this will leave invalid types in the cache when it fails
        validate(validationContext, cache);
    }

    return context.getResult();
}

From source file:com.zimbra.soap.voice.type.PhoneVoiceFeaturesInfo.java

public void setCallFeatures(Iterable<CallFeatureInfo> callFeatures) {
    this.callFeatures.clear();
    if (callFeatures != null) {
        Iterables.addAll(this.callFeatures, callFeatures);
    }/*from   w  ww. j a  v a 2  s  .com*/
}

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

public void setTypes(Iterable<IdsAttr> types) {
    this.types.clear();
    if (types != null) {
        Iterables.addAll(this.types, types);
    }//  ww w.j a  v a2s .  co  m
}

From source file:org.apache.hadoop.hive.ql.QueryLifeTimeHookRunner.java

/**
 * Constructs a {@link QueryLifeTimeHookRunner} that loads all hooks to be run via a {@link HooksLoader}.
 *
 * @param conf the {@link HiveConf} to use when creating {@link QueryLifeTimeHookContext} objects
 * @param hooksLoader the {@link HooksLoader} to use when loading all hooks to be run
 * @param console the {@link SessionState.LogHelper} to use when running {@link HooksLoader#getHooks(HiveConf.ConfVars)}
 *//*  w  w  w  .  j a  va  2 s.  c  om*/
QueryLifeTimeHookRunner(HiveConf conf, HooksLoader hooksLoader, SessionState.LogHelper console) {
    this.conf = conf;
    this.queryHooks = new ArrayList<>();

    if (conf.getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED)) {
        queryHooks.add(new MetricsQueryLifeTimeHook());
    }
    List<QueryLifeTimeHook> propertyDefinedHoooks;
    try {
        propertyDefinedHoooks = hooksLoader.getHooks(HiveConf.ConfVars.HIVE_QUERY_LIFETIME_HOOKS, console);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    }
    if (propertyDefinedHoooks != null) {
        Iterables.addAll(queryHooks, propertyDefinedHoooks);
    }
}

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

public Converter build() {
    final List<StreamFilter> filters = Lists.newLinkedList();

    if (nodePathTracker != null) {
        filters.add(nodePathTracker);/*from  www  .  j a  v  a  2  s .  co  m*/
    }

    Iterable<ConversionFilter> textStreamFilters = Iterables.filter(this.filters, ConversionFilter.class);

    Iterables.addAll(filters, Iterables.filter(textStreamFilters, ConversionFilter.BEFORE_TEXT_GENERATION));

    if (offsetMapper != null) {
        filters.add(offsetMapper);
    }
    if (whitespaceCompressor != null) {
        filters.add(whitespaceCompressor);
    }

    Iterables.addAll(filters,
            Iterables.filter(textStreamFilters, Predicates.not(ConversionFilter.BEFORE_TEXT_GENERATION)));
    Iterables.addAll(filters,
            Iterables.filter(this.filters, Predicates.not(Predicates.instanceOf(ConversionFilter.class))));

    return new Converter(whitespaceCompressor, offsetMapper, namespaceMapping, filters).add(listeners);
}

From source file:org.summer.dsl.xbase.scoping.featurecalls.DefaultFeaturesForTypeProvider.java

protected void collectFeatures(String name, JvmType rawType, List<JvmFeature> result) {
    if (rawType instanceof JvmDeclaredType) {
        if (name != null)
            Iterables.addAll(result, ((JvmDeclaredType) rawType).findAllFeaturesByName(name));
        else/*from   ww w .  jav  a2 s. c o  m*/
            Iterables.addAll(result, ((JvmDeclaredType) rawType).getAllFeatures());
    }
}

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

public void setInviteComponents(Iterable<InviteComponentWithGroupInfo> inviteComponents) {
    this.inviteComponents.clear();
    if (inviteComponents != null) {
        Iterables.addAll(this.inviteComponents, inviteComponents);
    }/*w w w .j  av  a2 s .  co m*/
}

From source file:io.github.mywarp.mywarp.warp.WarpBuilder.java

/**
 * Adds each playermatcher to the Warp.//from  w ww .j a  va2s  .  c o m
 *
 * @param invitations the invitations to add
 * @return this {@code WarpBuilder}
 */
public WarpBuilder addInvitations(Iterable<PlayerMatcher> invitations) {
    Iterables.addAll(this.invitations, invitations);
    return this;
}