List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:org.waveprotocol.wave.model.conversation.TagsDocument.java
static public ImmutableSet<String> getTags(Document doc) { final ImmutableSet.Builder<String> tags = ImmutableSet.builder(); @SuppressWarnings({ "unchecked", "rawtypes" }) TagsDocument tagsDocument = new TagsDocument(doc); tagsDocument.addListener(new TagsDocument.Listener() { @Override//from w w w . j a va 2 s. co m public void onAdd(String tagName) { tags.add(tagName); } @Override public void onRemove(int tagPosition) { // Not called. } }); tagsDocument.processInitialState(); return tags.build(); }
From source file:org.apache.druid.server.lookup.cache.polling.OnHeapPollingCache.java
public OnHeapPollingCache(Iterable<Map.Entry<K, V>> entries) { if (entries == null) { immutableMap = ImmutableMap.of(); immutableReverseMap = ImmutableMap.of(); } else {/* w ww.j a v a 2 s . c om*/ ImmutableSet.Builder<V> setOfValuesBuilder = ImmutableSet.builder(); ImmutableMap.Builder<K, V> mapBuilder = ImmutableMap.builder(); for (Map.Entry<K, V> entry : entries) { setOfValuesBuilder.add(entry.getValue()); mapBuilder.put(entry.getKey(), entry.getValue()); } final Set<V> setOfValues = setOfValuesBuilder.build(); immutableMap = mapBuilder.build(); immutableReverseMap = ImmutableMap .copyOf(Maps.asMap(setOfValues, val -> immutableMap.keySet().stream().filter(key -> { V retVal = immutableMap.get(key); return retVal != null && retVal.equals(val); }).collect(Collectors.toList()))); } }
From source file:com.google.gerrit.server.config.GroupSetProvider.java
@Inject protected GroupSetProvider(GroupBackend groupBackend, @GerritServerConfig Config config, String section, String subsection, String name) { String[] groupNames = config.getStringList(section, subsection, name); ImmutableSet.Builder<AccountGroup.UUID> builder = ImmutableSet.builder(); for (String n : groupNames) { GroupReference g = GroupBackends.findBestSuggestion(groupBackend, n); if (g == null) { log.warn("Group \"{0}\" not in database, skipping.", n); } else {//ww w. j a va2s.co m builder.add(g.getUUID()); } } groupIds = builder.build(); }
From source file:com.google.devtools.build.lib.runtime.BlazeCommandUtils.java
public static ImmutableSet<Class<? extends OptionsBase>> getCommonOptions(Iterable<BlazeModule> modules) { ImmutableSet.Builder<Class<? extends OptionsBase>> builder = ImmutableSet.builder(); builder.addAll(COMMON_COMMAND_OPTIONS); for (BlazeModule blazeModule : modules) { builder.addAll(blazeModule.getCommonCommandOptions()); }//from w w w . j a v a 2 s . com return builder.build(); }
From source file:zipkin.storage.cassandra.InsertTraceIdBySpanName.java
@Override public Set<String> partitionKeys(Span span) { if (span.name.isEmpty()) return Collections.emptySet(); ImmutableSet.Builder<String> result = ImmutableSet.builder(); for (String serviceName : span.serviceNames()) { result.add(serviceName + "." + span.name); }/*from w ww . ja v a 2 s.c o m*/ return result.build(); }
From source file:com.github.fge.jsonschema.keyword.validator.draftv3.PropertiesValidator.java
public PropertiesValidator(final JsonNode digest) { super("properties"); final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (final JsonNode element : digest.get("required")) builder.add(element.textValue()); required = builder.build();//w ww . j a va 2 s .com }
From source file:uk.ac.ebi.mdk.io.text.kegg.KEGGCompoundField.java
private KEGGCompoundField(String... names) { ImmutableSet.Builder<String> ns = new ImmutableSet.Builder<String>(); for (String name : names) { ns.add(name);/*from w ww.ja v a 2 s. co m*/ } ns.add(name()); this.names = ns.build(); }
From source file:com.github.fge.jsonschema.keyword.validator.draftv4.RequiredKeywordValidator.java
public RequiredKeywordValidator(final JsonNode digest) { super("required"); final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (final JsonNode element : digest.get(keyword)) builder.add(element.textValue()); required = builder.build();/*from w w w . j a va2 s . c om*/ }
From source file:org.androidtransfuse.transaction.TransactionProcessorChain.java
@Override public ImmutableSet<Exception> getErrors() { ImmutableSet.Builder<Exception> exceptions = ImmutableSet.builder(); exceptions.addAll(beforeProcessor.getErrors()); exceptions.addAll(afterProcessor.getErrors()); return exceptions.build(); }
From source file:org.obiba.onyx.marble.magma.ConsentVariableValueSourceFactory.java
@Override public Set<VariableValueSource> createSources() { Set<VariableValueSource> sources = null; ImmutableSet.Builder<Variable.BuilderVisitor> visitorSetBuilder = new ImmutableSet.Builder<Variable.BuilderVisitor>(); visitorSetBuilder.add(new StageAttributeVisitor(stageName), new PdfMimeTypeAttributeVisitor()); Set<Variable.BuilderVisitor> visitors = visitorSetBuilder.build(); // Create the non-PDF form sources. setProperties(ImmutableSet.of("mode", "locale", "accepted", "pdfForm", "timeStart", "timeEnd")); setVariableBuilderVisitors(visitors); sources = super.createSources(); // Create the PDF form sources. sources.addAll(createPdfFormFieldSources(visitors)); return sources; }