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.obiba.magma.datasource.mongodb.MongoDBDatasource.java

@NotNull
@Override/*from ww w .  j  a  va 2  s  .c  om*/
public Timestamps getTimestamps() {
    ImmutableSet.Builder<Timestamped> builder = ImmutableSet.builder();
    builder.addAll(getValueTables()).add(new MongoDBDatasourceTimestamped());
    return new UnionTimestamps(builder.build());
}

From source file:org.lanternpowered.server.service.user.LanternUserStorageService.java

private Collection<GameProfile> getAllProfiles() {
    final ImmutableSet.Builder<GameProfile> profiles = ImmutableSet.builder();
    profiles.addAll(
            this.server.getOnlinePlayers().stream().map(Player::getProfile).collect(Collectors.toSet()));
    profiles.addAll(this.banService.get().getBans().stream().filter(entry -> entry instanceof BanEntry.Profile)
            .map(entry -> ((BanEntry.Profile) entry).getProfile()).collect(Collectors.toSet()));
    profiles.addAll(this.whitelistService.get().getWhitelistedProfiles());
    return profiles.build();
}

From source file:org.obiba.opal.web.magma.ParticipantsResource.java

@GET
@Path("/count")
@NoAuthorization/* w  w w .j a  va2 s.  c  om*/
public Response getParticipantCount() {
    Set<Datasource> datasources = MagmaEngine.get().getDatasources();
    ImmutableSet.Builder<VariableEntity> participants = ImmutableSet.builder();
    for (Datasource ds : datasources) {
        for (ValueTable table : Iterables.filter(ds.getValueTables(),
                ParticipantEntityTypePredicate.INSTANCE)) {
            participants.addAll(table.getVariableEntities());
        }
    }
    return Response.ok(String.valueOf(participants.build().size())).build();
}

From source file:org.sosy_lab.cpachecker.cpa.validvars.ValidVars.java

public ValidVars mergeWith(ValidVars pOther) throws CPAException {
    if (!pOther.localValidVars.keySet().containsAll(localValidVars.keySet())) {
        throw new CPAException(
                "Require Callstack CPA to separate different function calls and Location CPA to separate different locations.");
    }/*from w  ww  . j  a  v  a  2  s  .c om*/

    boolean changed = false;

    // merge global vars
    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    builder.addAll(pOther.globalValidVars);
    builder.addAll(globalValidVars);

    ImmutableSet<String> newGlobals = builder.build();
    if (newGlobals.size() != pOther.globalValidVars.size()) {
        changed = true;
    }

    // merge local vars
    ImmutableSet<String> newLocalsForFun;
    ImmutableMap.Builder<String, ImmutableSet<String>> builderMap = ImmutableMap.builder();
    for (String funName : localValidVars.keySet()) {
        checkArgument(numFunctionCalled.get(funName).equals(pOther.numFunctionCalled.get(funName)),
                "Require Callstack CPA to separate different function calls.");
        builder = ImmutableSet.builder();
        builder.addAll(pOther.localValidVars.get(funName));
        builder.addAll(localValidVars.get(funName));

        newLocalsForFun = builder.build();
        if (newLocalsForFun.size() != pOther.localValidVars.get(funName).size()) {
            changed = true;
        }

        builderMap.put(funName, newLocalsForFun);
    }

    if (changed) {
        return new ValidVars(newGlobals, builderMap.build(), numFunctionCalled);
    }

    return pOther;
}

From source file:com.publictransitanalytics.scoregenerator.schedule.TripCreatingTransitNetwork.java

@Override
public Set<EntryPoint> getEntryPoints(final TransitStop stop, final LocalDateTime startTime,
        final LocalDateTime endTime) {
    final ImmutableSet.Builder<EntryPoint> builder = ImmutableSet.builder();

    final EntryPointTimeKey startKey = EntryPointTimeKey.getMinimalKey(startTime);
    final EntryPointTimeKey endKey = EntryPointTimeKey.getMaximalKey(endTime);
    builder.addAll(entryPoints.row(stop).subMap(startKey, endKey).values());
    if (entryPoints.contains(stop, endKey)) {
        builder.add(entryPoints.get(stop, endKey));
    }//from   w  w  w .  j  a v a2s  .c  om
    return builder.build();
}

From source file:org.fcrepo.kernel.rdf.impl.NodeRdfContext.java

private void concatRdfTypes() throws RepositoryException {
    final ImmutableList.Builder<NodeType> nodeTypesB = ImmutableList.<NodeType>builder();

    final NodeType primaryNodeType = node.getPrimaryNodeType();
    nodeTypesB.add(primaryNodeType);/*from  w w w .ja va  2s.c o m*/

    if (primaryNodeType != null && primaryNodeType.getSupertypes() != null) {
        final Set<NodeType> primarySupertypes = ImmutableSet.<NodeType>builder()
                .add(primaryNodeType.getSupertypes()).build();
        nodeTypesB.addAll(primarySupertypes);
    }

    final NodeType[] mixinNodeTypesArr = node.getMixinNodeTypes();

    if (mixinNodeTypesArr != null) {
        final Set<NodeType> mixinNodeTypes = ImmutableSet.<NodeType>builder().add(mixinNodeTypesArr).build();
        nodeTypesB.addAll(mixinNodeTypes);

        final ImmutableSet.Builder<NodeType> mixinSupertypes = ImmutableSet.<NodeType>builder();
        for (final NodeType mixinNodeType : mixinNodeTypes) {
            mixinSupertypes.addAll(ImmutableSet.<NodeType>builder().add(mixinNodeType.getSupertypes()).build());
        }

        nodeTypesB.addAll(mixinSupertypes.build());
    }

    final ImmutableList<NodeType> nodeTypes = nodeTypesB.build();
    final Iterator<NodeType> nodeTypesIt = nodeTypes.iterator();

    concat(Iterators.transform(nodeTypesIt, nodetype2triple()));
}

From source file:com.exoplatform.iversion.VersionNode.java

/**
 * Collects this revision and all of its parent's revision
 * /*from  w w  w  .  ja v  a  2  s .  c  o  m*/
 * @param revisions collector revision
 */
private void collectRevisions(ImmutableSet.Builder<Long> revisions) {
    revisions.add(getRevision());

    //
    for (VersionNode<K, V, M, T> parent : parents) {
        revisions.addAll(parent.getRevisions());
    }
}

From source file:com.facebook.buck.core.cell.impl.AbstractImmutableCell.java

@Override
@Value.Auxiliary//from   w  w w.  j  av  a2s . co m
@Value.Derived
public ProjectFilesystemView getFilesystemViewForSourceFiles() {
    ProjectFilesystem filesystem = getFilesystem();
    ImmutableSet.Builder<PathMatcher> ignores = ImmutableSet
            .builderWithExpectedSize(filesystem.getBlacklistedPaths().size() + 1);
    ignores.addAll(filesystem.getBlacklistedPaths());
    ignores.add(RecursiveFileMatcher.of(filesystem.getBuckPaths().getBuckOut()));
    for (Path subCellRoots : getKnownRoots()) {
        if (!subCellRoots.equals(getRoot())) {
            ignores.add(RecursiveFileMatcher.of(filesystem.relativize(subCellRoots)));
        }
    }
    return filesystem.asView().withView(Paths.get(""), ignores.build());
}

From source file:com.android.tools.idea.wizard.NewModuleWizardDynamic.java

private Collection<NewModuleDynamicPath> getContributedPaths() {
    ImmutableSet.Builder<NewModuleDynamicPath> builder = ImmutableSet.builder();
    for (NewModuleDynamicPathFactory factory : NewModuleDynamicPathFactory.EP_NAME.getExtensions()) {
        builder.addAll(factory.createWizardPaths(getProject(), getDisposable()));
    }//from w  w w  . java  2 s.  c  o m
    return builder.build();
}

From source file:com.facebook.buck.core.util.graph.MutableDirectedGraph.java

public ImmutableSet<ImmutableSet<T>> findCycles() {
    Set<Set<T>> cycles = Sets.filter(findStronglyConnectedComponents(),
            stronglyConnectedComponent -> stronglyConnectedComponent.size() > 1);
    Iterable<ImmutableSet<T>> immutableCycles = Iterables.transform(cycles, ImmutableSet::copyOf);

    // Tarjan's algorithm (as pseudo-coded on Wikipedia) does not appear to account for single-node
    // cycles. Therefore, we must check for them exclusively.
    ImmutableSet.Builder<ImmutableSet<T>> builder = ImmutableSet.builder();
    builder.addAll(immutableCycles);
    for (T node : nodes) {
        if (containsEdge(node, node)) {
            builder.add(ImmutableSet.of(node));
        }//from ww  w .jav a 2 s  .  co  m
    }
    return builder.build();
}