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.totsp.tom.Tom.java

@Override
public <C extends Collection<?>> C into(C collection) {
    Iterables.addAll((Collection) collection, asIterable());
    return collection;
}

From source file:org.yakindu.base.expressions.scoping.AbstractLibraryGlobalScopeProvider.java

protected Iterable<IEObjectDescription> getDescriptions(Resource context, URI uri) {
    List<IEObjectDescription> result = Lists.newArrayList();
    ResourceSet set = new ResourceSetImpl();
    Resource resource = set.getResource(uri, true);
    IResourceServiceProvider resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(uri);
    if (resourceServiceProvider == null) {
        Iterables.addAll(result, Scopes.scopedElementsFor(Lists.newArrayList(resource.getAllContents())));
    } else {/*from w  ww.ja v  a2  s  . co m*/
        IResourceDescription resourceDescription = resourceServiceProvider.getResourceDescriptionManager()
                .getResourceDescription(resource);
        Iterables.addAll(result, resourceDescription.getExportedObjects());
    }
    resource.unload();
    return result;
}

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

@Override
public void add(Iterable<Token> tokens) {
    final Set<Token> tokenSet = Sets.newHashSet(tokens());
    Iterables.addAll(tokenSet, tokens);
    setTokens(tokenSet);/*from w w  w .  jav a 2  s.  c o  m*/
}

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

private void pushUnsatisfiedDependencies(Iterable<? extends ModelSchemaExtractionContext<?>> allDependencies,
        Queue<ModelSchemaExtractionContext<?>> dependencyQueue, final ModelSchemaCache cache) {
    Iterables.addAll(dependencyQueue,
            Iterables.filter(allDependencies, new Predicate<ModelSchemaExtractionContext<?>>() {
                public boolean apply(ModelSchemaExtractionContext<?> dependency) {
                    return cache.get(dependency.getType()) == null;
                }//from w w w  .j  ava2 s.com
            }));
}

From source file:edu.umn.msi.tropix.common.collect.spring.JmxIterable.java

public void setContents(final Collection<T> initialContents) {
    synchronized (this.contents) {
        this.contents.clear();
        Iterables.addAll(this.contents, initialContents);
    }/*from w  ww.j a v a 2 s  .com*/
}

From source file:com.turn.ttorrent.tracker.TrackedPeer.java

/**
 * Update this peer's state and information.
 *
 * <p>//from   w ww.j ava 2  s . c  om
 * <b>Note:</b> if the peer reports 0 bytes left to download, its state will
 * be automatically be set to COMPLETED.
 * </p>
 *
 * @param torrent The torrent. This should be the same on every call.
 * @param state The peer's state.
 * @param uploaded Uploaded byte count, as reported by the peer.
 * @param downloaded Downloaded byte count, as reported by the peer.
 * @param left Left-to-download byte count, as reported by the peer.
 */
public void update(@Nonnull TrackedTorrent torrent, TrackedPeerState state,
        Iterable<? extends InetSocketAddress> peerAddresses, long uploaded, long downloaded, long left) {
    if (TrackedPeerState.STARTED.equals(state) && left == 0)
        state = TrackedPeerState.COMPLETED;

    if (!state.equals(this.state)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Peer {} {} download of {}.", new Object[] { this, state.name().toLowerCase(), torrent });
    }

    synchronized (lock) {
        Iterables.addAll(this.peerAddresses, peerAddresses);
        this.state = state;
        this.uploaded = uploaded;
        this.downloaded = downloaded;
        this.left = left;
        this.lastAnnounce = System.currentTimeMillis();
    }
}

From source file:de.learnlib.datastructure.discriminationtree.model.AbstractDiscriminationTree.java

@Override
public Collection<N> getNodes() {
    List<N> nodes = new ArrayList<>();
    Iterables.addAll(nodes, GraphTraversal.breadthFirstOrder(this, Collections.singleton(root)));
    return nodes;
}

From source file:com.zimbra.soap.account.type.Signature.java

public void setContent(Iterable<SignatureContent> content) {
    this.contentList.clear();
    if (content != null) {
        Iterables.addAll(this.contentList, content);
    }/*from w  w w .jav  a  2  s  .c om*/
}

From source file:org.jclouds.aws.ec2.domain.Image.java

public Image(String region, Architecture architecture, @Nullable String name, @Nullable String description,
        String imageId, String imageLocation, String imageOwnerId, ImageState imageState, ImageType imageType,
        boolean isPublic, Iterable<String> productCodes, @Nullable String kernelId, @Nullable String platform,
        @Nullable String ramdiskId, RootDeviceType rootDeviceType, @Nullable String rootDeviceName,
        Map<String, EbsBlockDevice> ebsBlockDevices, String virtualizationType) {
    this.region = checkNotNull(region, "region");
    this.architecture = checkNotNull(architecture, "architecture");
    this.imageId = checkNotNull(imageId, "imageId");
    this.name = name;
    this.description = description;
    this.rootDeviceName = rootDeviceName;
    this.imageLocation = checkNotNull(imageLocation, "imageLocation");
    this.imageOwnerId = checkNotNull(imageOwnerId, "imageOwnerId");
    this.imageState = checkNotNull(imageState, "imageState");
    this.imageType = checkNotNull(imageType, "imageType");
    this.isPublic = isPublic;
    this.kernelId = kernelId;
    this.platform = platform;
    Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes"));
    this.ramdiskId = ramdiskId;
    this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType");
    this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, "ebsBlockDevices"));
    this.virtualizationType = checkNotNull(virtualizationType, "virtualizationType");
}

From source file:com.google.gerrit.server.change.WalkSorter.java

public WalkSorter includePatchSets(Iterable<PatchSet.Id> patchSets) {
    Iterables.addAll(includePatchSets, patchSets);
    return this;
}