Example usage for com.google.common.collect ImmutableSet builder

List of usage examples for com.google.common.collect ImmutableSet builder

Introduction

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

Prototype

public static <E> Builder<E> builder() 

Source Link

Usage

From source file:io.airlift.discovery.ReplicatedStaticStore.java

@Override
public Set<Service> getAll() {
    ImmutableSet.Builder<Service> builder = ImmutableSet.builder();
    for (Entry entry : store.getAll()) {
        builder.add(codec.fromJson(entry.getValue()));
    }/*from w  w  w.j a v  a  2  s  .  c om*/

    return builder.build();
}

From source file:com.isotrol.impe3.core.component.CookieExtractors.java

private CookieExtractors(final Class<T> type, Iterable<Method> methods) {
    super(type);/*w ww  .ja v a  2s. c om*/
    final ImmutableSet.Builder<CookieExtractor> builder = ImmutableSet.builder();
    for (Method m : methods) {
        final CookieExtractor e = new CookieExtractor(m);
        builder.add(e);
    }
    this.extractors = builder.build();
}

From source file:org.onosproject.driver.optical.config.FlowTableConfig.java

public Set<FlowRule> flowtable() {
    JsonNode ents = object.path(ENTRIES);
    if (!ents.isArray()) {

        return ImmutableSet.of();
    }//from   ww  w.  j  a va  2  s.co m
    ArrayNode entries = (ArrayNode) ents;

    Builder<FlowRule> builder = ImmutableSet.builder();
    entries.forEach(entry -> builder.add(decode(entry, FlowRule.class)));
    return builder.build();
}

From source file:com.facebook.presto.sql.planner.assertions.StrictAssignedSymbolsMatcher.java

@Override
protected Set<Symbol> getExpectedSymbols(PlanNode node, Session session, Metadata metadata,
        SymbolAliases symbolAliases) {/*w  w  w  .  j  a  va  2  s  . com*/
    ImmutableSet.Builder<Symbol> expected = ImmutableSet.builder();
    for (RvalueMatcher matcher : getExpected) {
        Optional<Symbol> assigned = matcher.getAssignedSymbol(node, session, metadata, symbolAliases);
        if (!assigned.isPresent()) {
            return null;
        }

        expected.add(assigned.get());
    }

    return expected.build();
}

From source file:com.isotrol.impe3.core.component.ActionExtractors.java

private ActionExtractors(final Class<T> type, Iterable<Method> methods) {
    super(type);//from  w  w  w .  j  a  va2 s. c  o  m
    final ImmutableSet.Builder<ActionExtractor> builder = ImmutableSet.builder();
    for (Method m : methods) {
        final ActionExtractor e = new ActionExtractor(m);
        builder.add(e);
    }
    this.extractors = builder.build();
}

From source file:alluxio.yarn.YarnUtils.java

/**
 * Returns the host names for all nodes in yarnClient's YARN cluster.
 *
 * @param yarnClient the client to use to look up node information
 * @return the set of host names/*from   w  ww.j  av  a  2s.  c  o  m*/
 * @throws YarnException if an error occurs within YARN
 * @throws IOException if an error occurs in YARN's underlying IO
 */
public static Set<String> getNodeHosts(YarnClient yarnClient) throws YarnException, IOException {
    ImmutableSet.Builder<String> nodeHosts = ImmutableSet.builder();
    for (NodeReport runningNode : yarnClient.getNodeReports(USABLE_NODE_STATES)) {
        nodeHosts.add(runningNode.getNodeId().getHost());
    }
    return nodeHosts.build();
}

From source file:com.facebook.buck.artifact_cache.HttpArtifactCacheBinaryProtocol.java

public static StoreResponseReadResult readStoreRequest(DataInputStream input, OutputStream payloadSink)
        throws IOException {
    ImmutableSet.Builder<RuleKey> rawRuleKeys = ImmutableSet.builder();
    int ruleKeysCount = input.readInt();
    for (int i = 0; i < ruleKeysCount; i++) {
        rawRuleKeys.add(new RuleKey(input.readUTF()));
    }//from   www  .j a  v  a  2 s.  com

    MetadataAndPayloadReadResultInternal resultInternal = readMetadataAndPayload(input, payloadSink);

    StoreResponseReadResult.Builder result = StoreResponseReadResult.builder().from(resultInternal);
    result.setRawKeys(rawRuleKeys.build());
    return result.build();
}

From source file:com.facebook.presto.raptor.storage.CompactionSetCreator.java

public Set<Set<ShardMetadata>> getCompactionSets(Set<ShardMetadata> shardMetadata) {
    // Filter out shards larger than allowed size and sort in descending order of data size
    List<ShardMetadata> shards = shardMetadata.stream()
            .filter(shard -> shard.getUncompressedSize() < maxShardSize.toBytes())
            .sorted(comparing(ShardMetadata::getUncompressedSize).reversed())
            .collect(toCollection(ArrayList::new));

    ImmutableSet.Builder<Set<ShardMetadata>> compactionSets = ImmutableSet.builder();
    while (!shards.isEmpty()) {
        Set<ShardMetadata> compactionSet = getCompactionSet(shards);
        verify(!compactionSet.isEmpty());
        compactionSets.add(compactionSet);
        shards.removeAll(compactionSet);
    }/*from   w  w w  .  ja v  a 2 s. c  om*/
    return compactionSets.build();
}

From source file:uk.ac.ed.inf.ace.processors.RemoveStopwords.java

public RemoveStopwords(Engine<?, ?> engine, uk.ac.ed.inf.ace.config.v1.RemoveStopwords config)
        throws Exception {
    super(engine, config);
    File file = new File(config.getPathname());
    Preconditions.checkState(file.exists());

    FileReader fileReader = new FileReader(file);
    BufferedReader bufferedReader = new BufferedReader(fileReader);
    Builder<String> builder = ImmutableSet.builder();
    String line;//from  w w  w .j av  a2s. c om

    while ((line = bufferedReader.readLine()) != null) {
        line = line.trim();

        if (line.isEmpty()) {
            continue;
        }

        builder.add(line.toLowerCase());
    }

    stopwords = builder.build();
}

From source file:com.publictransitanalytics.scoregenerator.environment.SegmentExporter.java

public SegmentExporter(final Map<Long, Node> nodes) {
    builder = ImmutableSet.builder();
    this.nodes = nodes;
}