Example usage for com.google.common.collect ImmutableSet.Builder addAll

List of usage examples for com.google.common.collect ImmutableSet.Builder addAll

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet.Builder addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:org.androidtransfuse.transaction.TransactionProcessorChannel.java

@Override
public ImmutableSet<Exception> getErrors() {
    ImmutableSet.Builder<Exception> exceptions = ImmutableSet.builder();
    exceptions.addAll(completionProcessor.getErrors());
    exceptions.addAll(afterCompletionProcessor.getErrors());

    return exceptions.build();
}

From source file:es.udc.pfc.gamelib.chess.pieces.ChessBishop.java

public final ImmutableSet<Position> getMiniMoves(final ChessBoard board) {
    final ImmutableSet.Builder<Position> moves = ImmutableSet.builder();

    moves.addAll(getStandardMoves(board));

    for (final int[] element : special) {
        final Position pos = board.getPositionFor(this).relative(element[0], element[1]);

        if (board.isValidPosition(pos) && !board.isPieceAt(pos)) {
            moves.add(pos);//w ww .  j a va2  s .  c  o  m
        }
    }

    return moves.build();
}

From source file:org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub.java

@Override
public Iterable<ITmfEventAspect<?>> getEventAspects() {
    /*//from  ww w.  j  a  v  a 2  s.c  om
     * This method needs to fill the aspects dynamically because aspects in
     * the parent class are not all present at the beginning of the trace
     */
    ImmutableSet.Builder<ITmfEventAspect<?>> builder = ImmutableSet.builder();
    builder.addAll(super.getEventAspects());
    builder.add(KernelTidAspect.INSTANCE);
    builder.add(ThreadPriorityAspect.INSTANCE);
    return builder.build();
}

From source file:org.parceler.internal.TransactionProcessorParcelJoin.java

@Override
public ImmutableSet<Exception> getErrors() {
    ImmutableSet.Builder<Exception> builder = ImmutableSet.builder();
    builder.addAll(externalProcessor.getErrors());
    builder.addAll(parcelProcessor.getErrors());

    return builder.build();
}

From source file:org.seedstack.seed.web.security.internal.shiro.AbstractInjectionProvider.java

public AbstractInjectionProvider(Key<T> key) {
    this.key = key;
    constructorInjectionPoint = InjectionPoint.forConstructorOf(key.getTypeLiteral());

    ImmutableSet.Builder<Dependency<?>> dependencyBuilder = ImmutableSet.builder();
    dependencyBuilder.addAll(constructorInjectionPoint.getDependencies());
    for (InjectionPoint injectionPoint : InjectionPoint.forInstanceMethodsAndFields(key.getTypeLiteral())) {
        dependencyBuilder.addAll(injectionPoint.getDependencies());
    }/*from  ww w .ja  v a2 s.  c o m*/
    this.dependencies = dependencyBuilder.build();
}

From source file:at.ac.univie.isc.asio.security.ExpandAuthoritiesContainer.java

/**
 * Map all {@link org.springframework.security.core.authority.GrantedAuthoritiesContainer authority container}
 * to themselves and their contained authorities.
 * Only first level members are expanded, i.e. nested containers are not supported.
 *
 * @param authorities source authorities
 * @return authorities plus all contained ones
 *//*from   www  .j ava  2 s  .c o  m*/
@Override
public Set<GrantedAuthority> mapAuthorities(final Collection<? extends GrantedAuthority> authorities) {
    final ImmutableSet.Builder<GrantedAuthority> mapped = ImmutableSet.builder();
    mapped.addAll(authorities);
    for (final GrantedAuthoritiesContainer container : Iterables.filter(authorities,
            GrantedAuthoritiesContainer.class)) {
        for (final GrantedAuthority each : container.getGrantedAuthorities()) {
            mapped.add(each);
        }
    }
    final ImmutableSet<GrantedAuthority> result = mapped.build();
    log.debug("mapped source authority containers {} to contained authorities {}", authorities, result);
    return result;
}

From source file:org.eclipse.buildship.core.workspace.internal.DefaultCompositeGradleBuild.java

@Override
public CompositeGradleBuild withBuild(FixedRequestAttributes build) {
    ImmutableSet.Builder<FixedRequestAttributes> builds = ImmutableSet.builder();
    builds.addAll(this.builds);
    builds.add(build);/*from  ww w . j  a va 2 s . c  o  m*/
    return new DefaultCompositeGradleBuild(builds.build());
}

From source file:org.graylog2.alerts.EmailRecipients.java

public Set<String> getEmailRecipients() {
    if (resolvedEmails != null) {
        return resolvedEmails;
    }/*from  w  w  w . j ava2 s  . co  m*/

    final ImmutableSet.Builder<String> emails = ImmutableSet.builder();
    emails.addAll(this.emails);

    for (String username : usernames) {
        final User user = userService.load(username);

        if (user != null && !isNullOrEmpty(user.getEmail())) {
            // LDAP users might have multiple email addresses defined.
            // See: https://github.com/Graylog2/graylog2-server/issues/1439
            final Iterable<String> addresses = Splitter.on(",").omitEmptyStrings().trimResults()
                    .split(user.getEmail());
            emails.addAll(addresses);
        }
    }

    resolvedEmails = emails.build();

    return resolvedEmails;
}

From source file:org.apache.aurora.scheduler.http.Maintenance.java

private Multimap<String, String> getTasksByHosts(StoreProvider provider, Iterable<String> hosts) {
    if (Iterables.isEmpty(hosts)) {
        return ImmutableMultimap.of();
    }//w  ww .jav  a  2 s .c o m

    ImmutableSet.Builder<IScheduledTask> drainingTasks = ImmutableSet.builder();
    drainingTasks.addAll(
            provider.getTaskStore().fetchTasks(Query.slaveScoped(hosts).byStatus(Tasks.SLAVE_ASSIGNED_STATES)));
    return Multimaps.transformValues(Multimaps.index(drainingTasks.build(), Tasks::scheduledToSlaveHost),
            Tasks::id);
}

From source file:org.geogit.api.plumbing.DescribeFeatureType.java

/**
 * Retrieves the set of property descriptors for the given feature type.
 * /*from ww w  .  ja  v a 2s  .  c om*/
 * @return a sorted set of all the property descriptors of the feature type.
 */
@Override
public ImmutableSet<PropertyDescriptor> call() {
    Preconditions.checkState(featureType != null, "FeatureType has not been set.");

    FeatureType type = featureType.type();

    ImmutableSet.Builder<PropertyDescriptor> propertySetBuilder = new ImmutableSet.Builder<PropertyDescriptor>();

    propertySetBuilder.addAll(type.getDescriptors());

    return propertySetBuilder.build();
}