List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:com.linecorp.armeria.server.RegexPathMapping.java
private static Set<String> findParamNames(Pattern regex) { final Matcher matcher = NAMED_GROUP_PATTERN.matcher(regex.pattern()); final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); int pos = 0;/*from w w w. j ava 2s .c o m*/ while (matcher.find(pos)) { builder.add(matcher.group(1)); pos = matcher.end(); } return builder.build(); }
From source file:org.cebolla.injection.RepositoryRegister.java
public ImmutableCollection<?> getRepositoriesForDataClass(Class<?> dataClass) { ImmutableSet.Builder<Object> result = ImmutableSet.builder(); if (repositories.containsKey(dataClass)) { result.addAll(repositories.get(dataClass)); }//from ww w . jav a 2s. c o m for (Class<?> iface : dataClass.getInterfaces()) { result.addAll(getRepositoriesForDataClass(iface)); } if (dataClass.getSuperclass() != null) { result.addAll(getRepositoriesForDataClass(dataClass.getSuperclass())); } return result.build(); }
From source file:com.google.api.codegen.transformer.py.PythonSampleOutputImportTransformer.java
private static void addImports(ImmutableSet.Builder<ImportFileView> imports, MethodContext context, OutputView outputView) {/* w w w. j ava2s .com*/ if (outputView.kind() == OutputView.Kind.LOOP) { OutputView.LoopView loopView = (OutputView.LoopView) outputView; addImports(imports, context, loopView.body()); } else if (outputView.kind() == OutputView.Kind.PRINT) { addEnumImports(imports, context, (OutputView.PrintView) outputView); } }
From source file:org.apache.beam.sdk.testing.WindowSupplier.java
public static <W extends BoundedWindow> WindowSupplier of(Coder<W> coder, Iterable<W> windows) { ImmutableSet.Builder<byte[]> windowsBuilder = ImmutableSet.builder(); for (W window : windows) { try {//from w w w.j av a 2 s . c o m windowsBuilder.add(CoderUtils.encodeToByteArray(coder, window)); } catch (CoderException e) { throw new IllegalArgumentException( "Could not encode provided windows with the provided window coder", e); } } return new WindowSupplier(coder, windowsBuilder.build()); }
From source file:io.prestosql.sql.planner.SymbolsExtractor.java
public static Set<Symbol> extractUnique(PlanNode node) { ImmutableSet.Builder<Symbol> uniqueSymbols = ImmutableSet.builder(); extractExpressions(node).forEach(expression -> uniqueSymbols.addAll(extractUnique(expression))); return uniqueSymbols.build(); }
From source file:org.lenskit.LenskitInfo.java
private static Set<String> loadRevisionSet() { ImmutableSet.Builder<String> revisions = ImmutableSet.builder(); InputStream input = LenskitInfo.class.getResourceAsStream("/META-INF/lenskit/git-commits.lst"); if (input != null) { try (Reader reader = new InputStreamReader(input, Charsets.UTF_8); BufferedReader lines = new BufferedReader(reader)) { String line;/*from w ww . ja va 2s . c o m*/ while ((line = lines.readLine()) != null) { revisions.add(StringUtils.trim(line)); } } catch (IOException e) { logger.warn("Could not read Git revision list", e); } finally { try { input.close(); } catch (IOException e) { logger.error("error closing git-commit list", e); } } } else { logger.warn("cannot find LensKit revision list"); } Set<String> revset = revisions.build(); logger.debug("have {} active revisions", revset.size()); return revset; }
From source file:com.fitbur.core.guava.collect.provider.ImmutableSetBuilder.java
@Override public ImmutableSet.Builder provide() { return new ImmutableSet.Builder(); }
From source file:com.google.idea.blaze.base.lang.buildfile.language.semantics.BuiltInNamesProvider.java
/** Returns all built-in global symbols and function names. */ public static ImmutableSet<String> getBuiltInNames(Project project) { ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder().addAll(GLOBALS).addAll(FUNCTIONS); BuildLanguageSpec spec = BuildLanguageSpecProvider.getInstance().getLanguageSpec(project); if (spec != null) { builder = builder.addAll(spec.getKnownRuleNames()); }/*from w ww . j av a 2 s . com*/ return builder.build(); }
From source file:org.tensorics.core.tensor.variance.CoContraDimensionPairs.java
public static Set<Class<?>> rightDimensionsIn(Iterable<CoContraDimensionPair> pairs) { ImmutableSet.Builder<Class<?>> builder = ImmutableSet.builder(); for (CoContraDimensionPair pair : pairs) { builder.add(pair.right());/*from w w w. j a v a 2 s . co m*/ } return builder.build(); }
From source file:com.google.devtools.build.lib.rules.objc.Xcdatamodels.java
static Iterable<Xcdatamodel> xcdatamodels(IntermediateArtifacts intermediateArtifacts, Iterable<Artifact> xcdatamodels) { ImmutableSet.Builder<Xcdatamodel> result = new ImmutableSet.Builder<>(); Multimap<PathFragment, Artifact> artifactsByContainer = byContainer(xcdatamodels); for (Map.Entry<PathFragment, Collection<Artifact>> modelDirEntry : artifactsByContainer.asMap() .entrySet()) {//from ww w .j av a 2 s . co m PathFragment container = modelDirEntry.getKey(); Artifact outputZip = intermediateArtifacts.compiledMomZipArtifact(container); result.add(new Xcdatamodel(outputZip, ImmutableSet.copyOf(modelDirEntry.getValue()), container)); } return result.build(); }