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.thiesen.jiffs.jobs.clusterer.ClusterFinder.java

private Set<String> makeAllWordsSet(final Iterable<String> firstWords, final Iterable<String> secondWords) {
    final Set<String> allWords = Sets.newTreeSet();
    Iterables.addAll(allWords, firstWords);
    Iterables.addAll(allWords, secondWords);
    return allWords;
}

From source file:eu.esdihumboldt.hale.ui.util.groovy.internal.contentassist.GroovyASTCompletionProcessor.java

@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
    if (proposals == null || proposals.isEmpty()) {
        return null;
    }/*from   ww w . ja v a 2  s .c  om*/

    if (viewer instanceof CompilingSourceViewer<?>) {

        CompilingSourceViewer<?> csv = (CompilingSourceViewer<?>) viewer;
        try {
            Object compiled = csv.getCompiled().get();
            if (compiled instanceof GroovyAST) {
                // the Groovy AST
                GroovyAST ast = (GroovyAST) compiled;
                // the line (0-based)
                int line = csv.getDocument().getLineOfOffset(offset);
                // the line column (0-based)
                int column = offset - csv.getDocument().getLineOffset(line);
                // locations in Groovy AST are 1-based
                line++;
                column++;

                List<ICompletionProposal> list = new ArrayList<>();

                // add proposals of individual computers
                for (GroovyCompletionProposals proposal : proposals) {
                    Iterable<? extends ICompletionProposal> computed = proposal.computeProposals(viewer, ast,
                            line, column, offset);
                    if (computed != null) {
                        Iterables.addAll(list, computed);
                    }
                }

                return list.toArray(new ICompletionProposal[list.size()]);
            }
        } catch (Exception e) {
            log.warn("Failed to get AST to compute completion proposals", e);
        }
    }

    return null;
}

From source file:brooklyn.util.task.TaskBuilder.java

public TaskBuilder<T> addAll(Iterable<? extends TaskAdaptable<?>> additionalChildren) {
    Iterables.addAll(children, additionalChildren);
    return this;
}

From source file:vogar.android.HostRuntime.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 : modeId.getJarNames()) {
        jars.add(new File(buildRoot, "out/host/linux-x86/framework/" + jar + ".jar"));
    }//from  w ww .  j a  v  a2 s  .c o 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/" + run.vmCommand);

    String libDir = buildRoot + "/out/host/linux-x86";
    if (variant == Variant.X32) {
        libDir += "/lib";
    } else if (variant == Variant.X64) {
        libDir += "/lib64";
    } else {
        throw new AssertionError("Unsupported variant:" + variant);
    }
    builder.env("ANDROID_ROOT", buildRoot + "/out/host/linux-x86").env("LD_LIBRARY_PATH", libDir)
            .env("DYLD_LIBRARY_PATH", libDir);

    // If you edit this, see also DeviceRuntime...
    builder.vmCommand(vmCommand).vmArgs("-Xbootclasspath:" + bootClasspath.toString())
            .vmArgs("-Duser.language=en").vmArgs("-Duser.region=US");
    if (!run.benchmark) {
        if (modeId == ModeId.HOST_DALVIK) {
            // Historically, vogar has turned off these options for Dalvik.
            builder.vmArgs("-Xverify:none");
            builder.vmArgs("-Xdexopt:none");
        }
        builder.vmArgs("-Xcheck:jni");
    }
    if (modeId == ModeId.HOST_ART_KITKAT) {
        // Required for KitKat to select the ART runtime. Default is Dalvik.
        builder.vmArgs("-XXlib:libart.so");
    }
    // dalvikvm defaults to no limit, but the framework sets the limit at 2000.
    builder.vmArgs("-Xjnigreflimit:2000");
    return builder;
}

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

public Volume(String region, String id, int size, String snapshotId, String availabilityZone,
        Volume.Status status, Date createTime, Iterable<Attachment> attachments) {
    this.region = checkNotNull(region, "region");
    this.id = id;
    this.size = size;
    this.snapshotId = snapshotId;
    this.availabilityZone = availabilityZone;
    this.status = status;
    this.createTime = createTime;
    Iterables.addAll(this.attachments, attachments);
}

From source file:org.eclipse.incquery.validation.runtime.ConstraintExtensionRegistry.java

/**
 * Returns the registered constraint specifications for a particular editor Id.
 * //  w w  w.j  av a2  s .  c om
 * @param editorId
 *            The editor Id for which the constraint specifications should be retrieved.
 * @return The Set of constraint specifications registered.
 */
public static synchronized Set<IConstraintSpecification> getConstraintSpecificationsForEditorId(
        String editorId) {
    if (genericEditorIds.contains(editorId)) {
        Iterable<IConstraintSpecification> constraintSpecifications = unwrapConstraintSpecifications(
                getEditorConstraintSpecificationMap().values());
        return ImmutableSet.copyOf(constraintSpecifications);
    }
    Set<IConstraintSpecification> set = Sets
            .newHashSet(unwrapConstraintSpecifications(getEditorConstraintSpecificationMap().get(editorId)));
    Iterables.addAll(set, unwrapConstraintSpecifications(getEditorConstraintSpecificationMap().get("*")));
    return set;
}

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

public void setInviteComponents(Iterable<InviteComponent> inviteComponents) {
    this.inviteComponents.clear();
    if (inviteComponents != null) {
        Iterables.addAll(this.inviteComponents, inviteComponents);
    }//from   w  w w . j a va2  s . c o  m
}

From source file:be.nbb.jackcess.JackcessStatement.java

private static SortedSet<Column> mergeAndSortByInternalIndex(Iterable<Column>... list) {
    SortedSet<Column> result = Sets.newTreeSet(BY_COLUMN_INDEX);
    for (Iterable<Column> o : list) {
        Iterables.addAll(result, o);
    }/*  w  w  w  .  j a  va 2  s.c o m*/
    return result;
}

From source file:fr.letroll.ttorrentandroid.tracker.TrackedPeer.java

/**
 * Update this peer's state and information.
 *
 * <p>/*from  w  ww. java  2 s .  c o  m*/
 * <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)) {
        LOG.info("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:org.eclipse.sirius.diagram.ui.internal.operation.RegionContainerUpdateLayoutOperation.java

private List<Node> getRegionsToLayout() {
    List<Node> regionsToLayout = Lists.newArrayList();
    if (regionContainer != null) {
        Node labelNode = SiriusGMFHelper.getLabelNode(regionContainer);
        List<Node> nodes = Lists.newArrayList(Iterables.filter(regionContainer.getChildren(), Node.class));
        if (labelNode != null && nodes.size() == 2) {
            nodes.remove(labelNode);// w w  w . j  a v a2 s  .  co  m
            Node compartment = nodes.iterator().next();
            Iterables.addAll(regionsToLayout, Iterables.filter(compartment.getChildren(), Node.class));
        }
    }
    return regionsToLayout;
}