List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:org.bitcoinj.params.Networks.java
public static void unregister(NetworkParameters network) { if (networks.contains(network)) { ImmutableSet.Builder<NetworkParameters> builder = ImmutableSet.builder(); for (NetworkParameters parameters : networks) { if (parameters.equals(network)) continue; builder.add(parameters);//from w ww .j a v a2 s .c o m } networks = builder.build(); } }
From source file:org.zanata.rest.service.MockResourcesApplication.java
@SuppressWarnings("deprecation") //TODO: replace with MockProjectVersionResource private static void addDeprecatedResource(ImmutableSet.Builder<Class<?>> builder) { builder.add(MockProjectIterationResource.class); }
From source file:com.google.caliper.runner.resultprocessor.ResultProcessorModule.java
@Provides static ImmutableSet<ResultProcessor> provideResultProcessors(CaliperConfig config, Map<Class<? extends ResultProcessor>, Provider<ResultProcessor>> availableProcessors) { ImmutableSet.Builder<ResultProcessor> builder = ImmutableSet.builder(); for (Class<? extends ResultProcessor> processorClass : config.getConfiguredResultProcessors()) { Provider<ResultProcessor> resultProcessorProvider = availableProcessors.get(processorClass); ResultProcessor resultProcessor = resultProcessorProvider == null ? ResultProcessorCreator.createResultProcessor(processorClass) : resultProcessorProvider.get(); builder.add(resultProcessor);//from w w w . j a va 2s . c o m } return builder.build(); }
From source file:com.facebook.buck.io.FileFinder.java
/** * Combines prefixes, base, and suffixes to create a set of file names. * @param prefixes set of prefixes. May be null or empty. * @param base base name. May be empty.//from www. j a va2s. c o m * @param suffixes set of suffixes. May be null or empty. * @return a set containing all combinations of prefix, base, and suffix. */ public static ImmutableSet<String> combine(@Nullable Set<String> prefixes, String base, @Nullable Set<String> suffixes) { ImmutableSet<String> suffixedSet; if (suffixes == null || suffixes.isEmpty()) { suffixedSet = ImmutableSet.of(base); } else { ImmutableSet.Builder<String> suffixedBuilder = ImmutableSet.builder(); for (String suffix : suffixes) { suffixedBuilder.add(base + suffix); } suffixedSet = suffixedBuilder.build(); } if (prefixes == null || prefixes.isEmpty()) { return suffixedSet; } else { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (String prefix : prefixes) { for (String suffix : suffixedSet) { builder.add(prefix + suffix); } } return builder.build(); } }
From source file:be.fror.common.function.MoreCollectors.java
/** * Returns a <tt>Collector</tt> that accumulates the input elements into a new * <tt>ImmutableSet</tt>. The returned <tt>ImmutableSet</tt> is guaranteed to be immutable, * serializable and thread-safe./*from w w w.ja v a 2 s . c o m*/ * * @param <T> the type of the input elements * @return a Collector which collects all the input elements into a ImmutableSet, in encounter * order */ public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() { return Collector.of(ImmutableSet.Builder::new, ImmutableSet.Builder::add, (l, r) -> l.addAll(r.build()), ImmutableSet.Builder<T>::build); }
From source file:com.tyler.collectors.GuavaCollectors.java
public static <T> Collector<T, ?, ImmutableSet<T>> toImmutableSet() { return Collector.of(ImmutableSet.Builder<T>::new, ImmutableSet.Builder<T>::add, (l, r) -> l.addAll(r.build()), ImmutableSet.Builder<T>::build); }
From source file:suneido.database.immudb.ForeignKeyTargets.java
ForeignKeyTargets with(ForeignKey source, ForeignKeyTarget target) { ImmutableSet.Builder<ForeignKeyTarget> fks = ImmutableSet.builder(); Set<ForeignKeyTarget> cur = targets.get(source); if (cur != null) fks.addAll(cur);/*w ww . j av a 2s. c om*/ fks.add(target); return new ForeignKeyTargets(targets.with(source, fks.build())); }
From source file:org.graylog2.indexer.results.HighlightParser.java
private static Set<Range<Integer>> extractRange(List<String> highlights) { final ImmutableSet.Builder<Range<Integer>> builder = ImmutableSet.builder(); highlights.forEach(highlight -> { final Matcher matcher = highlightPattern.matcher(highlight); Integer count = -1;/* w w w . j a v a2 s.com*/ while (matcher.find()) { count++; final Integer start = matcher.start() - count * (startTokenLength + endTokenLength); final Integer end = start + (matcher.end(1) - matcher.start(1)); builder.add(Range.closed(start, end)); } }); return builder.build(); }
From source file:com.google.doubleclick.openrtb.CompanionTypeMapper.java
public static ImmutableSet<CreativeFormat> toDoubleClick(Collection<CompanionType> openrtbList) { ImmutableSet.Builder<CreativeFormat> dcSet = ImmutableSet.builder(); for (CompanionType openrtb : openrtbList) { CreativeFormat dc = toDoubleClick(openrtb); if (dc != null) { dcSet.add(dc);/* w w w . ja v a 2s . c o m*/ } } return dcSet.build(); }
From source file:com.facebook.presto.sql.planner.DependencyExtractor.java
public static Set<QualifiedName> extractNames(Expression expression, Set<Expression> columnReferences) { ImmutableSet.Builder<QualifiedName> builder = ImmutableSet.builder(); new QualifiedNameBuilderVisitor(columnReferences).process(expression, builder); return builder.build(); }