List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:org.openqa.selenium.buck.javascript.JavascriptDependencies.java
@VisibleForTesting Set<JavascriptSource> getDeps(String required) { ImmutableSet.Builder<JavascriptSource> deps = ImmutableSet.builder(); Queue<String> toFind = new ArrayDeque<>(); Set<String> seen = Sets.newHashSet(); toFind.add(required);/*from w w w . j av a2 s . c o m*/ while (!toFind.isEmpty()) { String dep = toFind.remove(); if (seen.contains(dep)) { continue; } seen.add(dep); JavascriptSource source = provide2Source.get(dep); if (source == null) { continue; } deps.add(source); toFind.addAll(source.getRequires()); } return deps.build(); }
From source file:io.github.mywarp.mywarp.bukkit.BukkitGame.java
@Override public ImmutableSet<LocalWorld> getWorlds() { ImmutableSet.Builder<LocalWorld> builder = ImmutableSet.builder(); for (World world : Bukkit.getWorlds()) { builder.add(BukkitAdapter.adapt(world)); }/* w w w . j a va 2 s . c o m*/ return builder.build(); }
From source file:co.cask.cdap.app.program.ManifestFields.java
/** * Parses the manifest {@link #EXPORT_PACKAGE} attribute and returns a set of export packages. *///from w w w . j a v a2 s . c o m public static Set<String> getExportPackages(@Nullable Manifest manifest) { if (manifest == null) { return ImmutableSet.of(); } ImmutableSet.Builder<String> result = ImmutableSet.builder(); String exportPackages = manifest.getMainAttributes().getValue(ManifestFields.EXPORT_PACKAGE); if (exportPackages == null) { return result.build(); } // The matcher matches the package name one by one. Matcher matcher = EXPORT_PACKAGE_PATTERN.matcher(exportPackages); int start = 0; while (matcher.find(start)) { result.add(matcher.group(1)); start = matcher.end(); } return result.build(); }
From source file:org.apache.druid.server.lookup.cache.polling.OffHeapPollingCache.java
public OffHeapPollingCache(final Iterable<Map.Entry<K, V>> entries) { synchronized (started) { this.cacheName = StringUtils.format("cache-%s", UUID.randomUUID()); this.reverseCacheName = StringUtils.format("reverseCache-%s", UUID.randomUUID()); mapCache = DB.createHashMap(cacheName).make(); reverseCache = DB.createHashMap(reverseCacheName).make(); ImmutableSet.Builder<V> setOfValuesBuilder = ImmutableSet.builder(); for (Map.Entry<K, V> entry : entries) { mapCache.put(entry.getKey(), entry.getValue()); setOfValuesBuilder.add(entry.getValue()); }//from w ww.j av a 2s . c o m final Set<V> setOfValues = setOfValuesBuilder.build(); reverseCache.putAll(Maps.asMap(setOfValues, new Function<V, List<K>>() { @Override public List<K> apply(final V input) { return Lists.newArrayList(Maps.filterKeys(mapCache, new Predicate<K>() { @Override public boolean apply(K key) { V retVal = mapCache.get(key); if (retVal == null) { return false; } return retVal.equals(input); } }).keySet()); } })); started.getAndSet(true); } }
From source file:suneido.database.query.Rename.java
private static Set<String> rename_fields(Set<String> f, List<String> from, List<String> to) { ImmutableSet.Builder<String> new_fields = ImmutableSet.builder(); for (String s : f) { int j = from.indexOf(s); new_fields.add(j == -1 ? s : to.get(j)); }//from w w w . j a v a 2 s. co m return new_fields.build(); }
From source file:com.hengyi.japp.sap.convert.impl.SapConverts.java
private ISapConvert newInstance() throws Exception { ImmutableSet.Builder<IFieldCopy> fieldCoyps = ImmutableSet.builder(); PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(beanClass); if (descriptors == null) { return null; }/*from w w w . j a va2 s . c o m*/ for (PropertyDescriptor descriptor : descriptors) { String sapFieldName = getSapFieldName(descriptor); if (sapFieldName == null) { continue; } IFieldCopy fieldCopy = FieldCopys.begin().addBeanClass(beanClass).addBeanPropertyDescriptor(descriptor) .addRecordMetaData(metaData).addSapFieldName(sapFieldName).build(); if (fieldCopy != null) { fieldCoyps.add(fieldCopy); } } return new SapConvert(fieldCoyps.build()); }
From source file:com.linecorp.armeria.server.GlobPathMapping.java
GlobPathMapping(String glob) { final PatternAndParamCount patternAndParamCount = globToRegex(glob); this.glob = glob; pattern = patternAndParamCount.pattern; numParams = patternAndParamCount.numParams; final ImmutableSet.Builder<String> paramNames = ImmutableSet.builder(); for (int i = 0; i < numParams; i++) { paramNames.add(int2str(i)); }// w w w. ja v a 2s. c o m this.paramNames = paramNames.build(); loggerName = loggerName(glob); strVal = PREFIX + glob; }
From source file:co.cask.cdap.security.authorization.DefaultPrivilegesFetcherProxyService.java
@Override public Set<Privilege> listPrivileges(Principal principal) throws Exception { ImmutableSet.Builder<Privilege> privileges = ImmutableSet.builder(); for (Map.Entry<EntityId, Set<Action>> entry : getPrivileges(principal).entrySet()) { for (Action action : entry.getValue()) { privileges.add(new Privilege(entry.getKey(), action)); }//from w ww . j a v a 2 s. com } Set<Privilege> result = privileges.build(); LOG.debug("Fetched privileges for principal {} as {}", principal, result); return result; }
From source file:com.google.devtools.moe.client.database.FileDb.java
@Override public Set<Revision> findEquivalences(Revision revision, String otherRepository) { ImmutableSet.Builder<Revision> equivalentToRevision = ImmutableSet.builder(); for (RepositoryEquivalence e : dbStorage.equivalences()) { if (e.hasRevision(revision)) { Revision otherRevision = e.getOtherRevision(revision); if (otherRevision.repositoryName().equals(otherRepository)) { equivalentToRevision.add(otherRevision); }/*from w w w .j av a 2 s .com*/ } } return equivalentToRevision.build(); }