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.tyrannyofheaven.bukkit.zPermissions.region.WorldGuardRegionStrategy.java

@Override
public Set<String> getRegions(Location location, Player player) {
    if (isEnabled()) {
        RegionManager rm = worldGuardPlugin.getRegionManager(location.getWorld());
        if (rm != null) {
            ApplicableRegionSet ars = rm.getApplicableRegions(location);
            // Note, sorted from high to low priority, i.e. reverse application order
            List<ProtectedRegion> sorted = new ArrayList<>();
            Iterables.addAll(sorted, ars);
            Collections.reverse(sorted); // Now it is in application order

            Set<String> result = new LinkedHashSet<>(); // Preserve ordering for resolver
            for (ProtectedRegion pr : sorted) {
                // Ignore global region
                if (!"__global__".equals(pr.getId())) // NB: Hardcoded and not available as constant in WorldGuard
                    result.add(pr.getId().toLowerCase());
            }/*from   w  w w  . j a  v a  2  s .co m*/
            return result;
        }
    }
    return Collections.emptySet();
}

From source file:com.google.gerrit.server.account.GetCapabilities.java

@Option(name = "-q", metaVar = "CAP", multiValued = true, usage = "Capability to inspect")
void addQuery(String name) {
    if (query == null) {
        query = Sets.newHashSet();//from   w  ww  . j a v a 2  s. c  o m
    }
    Iterables.addAll(query, OptionUtil.splitOptionValue(name));
}

From source file:de.unipassau.isl.evs.ssh.core.sec.Permission.java

private static List<Permission> filter(Predicate<Permission> predicate) {
    final ArrayList<Permission> list = new ArrayList<>();
    final Iterable<Permission> iterable = Iterables.filter(Arrays.asList(values()), predicate);
    Iterables.addAll(list, iterable);
    return Collections.unmodifiableList(list);
}

From source file:org.jclouds.vcloud.domain.internal.VDCImpl.java

public VDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org,
        @Nullable String description, Iterable<Task> tasks, AllocationModel allocationModel,
        @Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity,
        Map<String, ReferenceType> resourceEntities, Map<String, ReferenceType> availableNetworks, int nicQuota,
        int networkQuota, int vmQuota, boolean isEnabled) {
    super(name, type, id);
    this.status = checkNotNull(status, "status");
    this.org = org;// TODO: once <1.0 is killed check not null
    this.description = description;
    Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
    this.allocationModel = checkNotNull(allocationModel, "allocationModel");
    this.storageCapacity = storageCapacity;// TODO: once <1.0 is killed check not null
    this.cpuCapacity = cpuCapacity;// TODO: once <1.0 is killed check not null
    this.memoryCapacity = memoryCapacity;// TODO: once <1.0 is killed check not null
    this.resourceEntities.putAll(checkNotNull(resourceEntities, "resourceEntities"));
    this.availableNetworks.putAll(checkNotNull(availableNetworks, "availableNetworks"));
    this.nicQuota = nicQuota;
    this.networkQuota = networkQuota;
    this.vmQuota = vmQuota;
    this.isEnabled = isEnabled;
}

From source file:com.google.javascript.jscomp.NameReferenceGraphReport.java

/**
 * Generate a nice HTML file describing the name reference graph.
 * For each declaration, list the sites where the declaration's name
 * is referenced, and list all the names that the declaration references.
 * For each, name exactly where use occurs in the source code.
 *
 * <p>This report should be useful both for internal compiler
 * developers and for engineers trying to understand running
 * behavior of their code or who want to understand why
 * AbstractCompiler won't move their code into a new module.
 *
 * @return String containing the entire HTML for the report.
 *//*from   www.j a  v a2 s. com*/
public String getHtmlReport() {
    StringBuilder builder = new StringBuilder();
    List<DiGraphNode<Name, Reference>> nodes = new ArrayList<>();
    Iterables.addAll(nodes, graph.getDirectedGraphNodes());

    generateHtmlReportHeader(builder);

    builder.append("<h1>Name Reference Graph Dump</h1>\n");
    builder.append("OVERALL STATS\n");
    builder.append("<ul>\n");
    builder.append("<li>Total names: " + nodes.size());
    builder.append("</ul>\n");

    builder.append("ALL NAMES\n");
    builder.append("<UL>\n");

    // Sort declarations in alphabetical order.
    Collections.sort(nodes, new DiGraphNodeComparator());

    for (DiGraphNode<Name, Reference> n : nodes) {
        // Generate the HTML describing the declaration itself.
        generateDeclarationReport(builder, n);

        // Next, list the places where this name is used (REFERS TO), and the
        // names that this declaration refers to (REFERENCED BY).
        List<DiGraphEdge<Name, Reference>> outEdges = graph.getOutEdges(n.getValue());
        List<DiGraphEdge<Name, Reference>> inEdges = graph.getInEdges(n.getValue());

        // Don't bother to create the dotted list if we don't have anything to
        // put in it.
        if (!outEdges.isEmpty() || !inEdges.isEmpty()) {
            builder.append("<ul>");

            if (!outEdges.isEmpty()) {
                builder.append("<li>REFERS TO:<br>\n");
                builder.append("<ul>");
                for (DiGraphEdge<Name, Reference> edge : outEdges) {
                    generateEdgeReport(builder, edge.getDestination().getValue(), edge);
                }
                builder.append("</ul>\n");
            }

            if (!inEdges.isEmpty()) {
                builder.append("<li>REFERENCED BY:<br>\n");
                builder.append("<ul>");
                for (DiGraphEdge<Name, Reference> edge : inEdges) {
                    generateEdgeReport(builder, edge.getSource().getValue(), edge);
                }
                builder.append("</ul>");
            }
            builder.append("</ul>\n");
        }
    }
    builder.append("</ul>\n");
    generateHtmlReportFooter(builder);
    return builder.toString();
}

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

public void setEntries(Iterable<CacheEntrySelector> entryList) {
    this.entries.clear();
    if (entryList != null) {
        Iterables.addAll(this.entries, entryList);
    }//from  w  w w .  j av  a2  s  . com
}

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

public void setConditions(Iterable<SearchFilterCondition> conditions) {
    this.conditions.clear();
    if (conditions != null) {
        Iterables.addAll(this.conditions, conditions);
    }//from  ww  w  .  j ava  2  s. c om
}

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

public <T> ModelSchema<T> extract(ModelType<T> type, ModelSchemaCache cache) {
    ModelSchemaExtractionContext<T> context = ModelSchemaExtractionContext.root(type);
    List<ModelSchemaExtractionContext<?>> validations = Lists.newLinkedList();
    Queue<ModelSchemaExtractionContext<?>> unsatisfiedDependencies = Lists.newLinkedList();
    ModelSchemaExtractionContext<?> extractionContext = context;
    validations.add(extractionContext);/*from w  w w .ja v a 2 s  .c om*/

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

    for (ModelSchemaExtractionContext<?> 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:eu.interedition.collatex.jung.JungVariantGraphVertex.java

@Override
public void add(Iterable<Token> tokens) {
    Iterables.addAll(this.tokens, tokens);
}

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

public void setRights(Iterable<String> rights) {
    this.rights.clear();
    if (rights != null) {
        Iterables.addAll(this.rights, rights);
    }/* w w w  .  java2s .co  m*/
}