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.opengamma.provider.security.SecurityEnhancerRequest.java

/**
 * Adds a collection of securities to those to be enhanced.
 * // w  w w .  j av a2s. c om
 * @param securities  the securities to enhance, not null
 */
public void addSecurities(Iterable<? extends Security> securities) {
    ArgumentChecker.notNull(securities, "securities");
    Iterables.addAll(getSecurities(), securities);
}

From source file:org.eclipse.xtext.xtext.XtextMetamodelReferenceHelper.java

private static void filterExactMatches(final String alias,
        final List<AbstractMetamodelDeclaration> importedMetamodels,
        final List<AbstractMetamodelDeclaration> exactMatches) {
    Iterables.addAll(exactMatches,
            Iterables.filter(importedMetamodels, new Predicate<AbstractMetamodelDeclaration>() {
                @Override//w  w  w.j a v a  2  s .  co m
                public boolean apply(AbstractMetamodelDeclaration param) {
                    return alias.equals(param.getAlias());
                }
            }));
}

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

public void setMimeParts(Iterable<MimePartInfo> mimeParts) {
    this.mimeParts.clear();
    if (mimeParts != null) {
        Iterables.addAll(this.mimeParts, mimeParts);
    }/*from  ww w .ja  v a2  s.com*/
}

From source file:org.xwiki.search.solr.internal.reference.WikiSolrReferenceResolver.java

@Override
public List<EntityReference> getReferences(EntityReference wikiReference) throws SolrIndexerException {
    List<EntityReference> result = new ArrayList<EntityReference>();

    // Ignore the wiki reference because it is not indexable.

    List<String> localSpaceRefs = null;

    // Make sure the list of spaces is from the requested wiki.
    try {//w  ww.java  2  s . c o m
        localSpaceRefs = this.queryManager.getNamedQuery("getSpaces").setWiki(wikiReference.getName())
                .execute();
    } catch (QueryException e) {
        throw new SolrIndexerException("Failed to query wiki [" + wikiReference.getName() + "] spaces", e);
    }

    // Visit each space
    for (String localSpaceRef : localSpaceRefs) {
        EntityReference spaceReference = this.explicitEntityReferenceResolver.resolve(localSpaceRef,
                EntityType.SPACE, wikiReference);

        try {
            Iterables.addAll(result, this.spaceResolverProvider.get().getReferences(spaceReference));
        } catch (Exception e) {
            this.logger.error("Failed to resolve references for space [" + spaceReference + "]", e);
        }
    }

    return result;
}

From source file:com.github.djabry.platform.service.security.DefaultUserDetails.java

/**
 * Returns the authorities granted to the user. Cannot return <code>null</code>.
 *
 * @return the authorities, sorted by natural key (never <code>null</code>)
 *//*from  www .ja v a2s  . com*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    Set<Permission> permissions = permissionMapper.mapPermissions(userAccount.getRole());

    Set<GrantedAuthority> authorities = Sets
            .newLinkedHashSet(Iterables.transform(permissions, PERMISSION_CONVERTER));
    Iterator<Group> iterator = userAccount.getGroups().iterator();
    while (iterator.hasNext()) {
        Group next = iterator.next();
        Iterables.addAll(authorities, Iterables.transform(next.getPermissions(), PERMISSION_CONVERTER));
    }

    return authorities;
}

From source file:com.google.devtools.build.lib.skyframe.TargetPatternFunction.java

@Override
public SkyValue compute(SkyKey key, Environment env)
        throws TargetPatternFunctionException, InterruptedException {
    TargetPatternValue.TargetPatternKey patternKey = ((TargetPatternValue.TargetPatternKey) key.argument());
    ResolvedTargets<Target> resolvedTargets;
    try {/*w  w w  . j a v  a2 s .  com*/
        EnvironmentBackedRecursivePackageProvider provider = new EnvironmentBackedRecursivePackageProvider(env);
        RecursivePackageProviderBackedTargetPatternResolver resolver = new RecursivePackageProviderBackedTargetPatternResolver(
                provider, env.getListener(), patternKey.getPolicy(),
                MultisetSemaphore.<PackageIdentifier>unbounded());
        TargetPattern parsedPattern = patternKey.getParsedPattern();
        ImmutableSet<PathFragment> excludedSubdirectories = patternKey.getExcludedSubdirectories();
        final Set<Target> results = CompactHashSet.create();
        BatchCallback<Target, RuntimeException> callback = new BatchCallback<Target, RuntimeException>() {
            @Override
            public void process(Iterable<Target> partialResult) {
                Iterables.addAll(results, partialResult);
            }
        };
        parsedPattern.eval(resolver, excludedSubdirectories, callback, RuntimeException.class);
        resolvedTargets = ResolvedTargets.<Target>builder().addAll(results).build();
    } catch (TargetParsingException e) {
        throw new TargetPatternFunctionException(e);
    } catch (MissingDepException e) {
        // The EnvironmentBackedRecursivePackageProvider constructed above might throw
        // MissingDepException to signal when it has a dependency on a missing Environment value.
        // Note that MissingDepException extends RuntimeException because the methods called
        // on EnvironmentBackedRecursivePackageProvider all belong to an interface shared with other
        // implementations that are unconcerned with MissingDepExceptions.
        return null;
    }
    Preconditions.checkNotNull(resolvedTargets, key);
    ResolvedTargets.Builder<Label> resolvedLabelsBuilder = ResolvedTargets.builder();
    for (Target target : resolvedTargets.getTargets()) {
        resolvedLabelsBuilder.add(target.getLabel());
    }
    for (Target target : resolvedTargets.getFilteredTargets()) {
        resolvedLabelsBuilder.remove(target.getLabel());
    }
    return new TargetPatternValue(resolvedLabelsBuilder.build());
}

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

public void setTimezones(Iterable<CalTZInfo> timezones) {
    this.timezones.clear();
    if (timezones != null) {
        Iterables.addAll(this.timezones, timezones);
    }//from   w  w w  .  j  a  v  a 2  s .c  om
}

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

@Override
public void setKeyValuePairs(Iterable<KeyValuePair> keyValues) {
    if (this.keyValuePairs == null) {
        this.keyValuePairs = Lists.newArrayList();
    }//w  w w . ja  v a 2  s.c o  m
    this.keyValuePairs.clear();
    if (keyValues != null) {
        Iterables.addAll(this.keyValuePairs, keyValues);
    }
}

From source file:com.kixeye.chassis.transport.swagger.CustomModelPropertiesProvider.java

@Override
public Iterable<? extends ModelProperty> propertiesForDeserialization(ResolvedType type) {
    List<ModelProperty> deserializableProperties = newArrayList();
    Iterables.addAll(deserializableProperties,
            defaultModelPropertiesProvider.propertiesForDeserialization(type));
    wrapModelProperties(deserializableProperties);
    return addConstructors(deserializableProperties, type);
}

From source file:com.google.gerrit.server.index.SchemaUtil.java

public static Set<String> getNameParts(String name, Iterable<String> emails) {
    Splitter at = Splitter.on('@');
    Splitter s = Splitter.on(CharMatcher.anyOf("@.- /_")).omitEmptyStrings();
    HashSet<String> parts = new HashSet<>();
    for (String email : emails) {
        if (email == null) {
            continue;
        }//  ww w  . ja v a 2 s  .co m
        String lowerEmail = email.toLowerCase(Locale.US);
        parts.add(lowerEmail);
        Iterables.addAll(parts, at.split(lowerEmail));
        Iterables.addAll(parts, s.split(lowerEmail));
    }
    if (name != null) {
        Iterables.addAll(parts, s.split(name.toLowerCase(Locale.US)));
    }
    return parts;
}