List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:jbyoshi.robotgame.util.StreamHelpers.java
public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() { return Collector.<E, ImmutableSet.Builder<E>, ImmutableSet<E>>of(ImmutableSet::builder, ImmutableSet.Builder::add, (one, two) -> one.addAll(two.build()), ImmutableSet.Builder::build); }
From source file:org.gradle.api.internal.artifacts.configurations.Configurations.java
public static ImmutableSet<String> getNames(Collection<Configuration> configurations) { if (configurations.isEmpty()) { return ImmutableSet.of(); } else if (configurations.size() == 1) { return ImmutableSet.of(configurations.iterator().next().getName()); }/*ww w . jav a 2 s. c o m*/ ImmutableSet.Builder<String> names = new ImmutableSet.Builder<String>(); for (Configuration configuration : configurations) { names.add(configuration.getName()); } return names.build(); }
From source file:ninja.leaping.permissionsex.util.GuavaCollectors.java
public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() { return Collector.of(ImmutableSet::builder, ImmutableSet.Builder::add, (a, b) -> a.addAll(b.build()), ImmutableSet.Builder::build); }
From source file:org.wso2.carbon.registry.social.api.utils.EnumUtil.java
/** * @param vals array of enums/*from w ww .j a va 2 s . c o m*/ * @return a set of the names for a list of Enum values defined by toString */ public static Set<String> getEnumStrings(java.lang.Enum<?>... vals) { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (java.lang.Enum<?> v : vals) { builder.add(v.toString()); } Set<String> result = builder.build(); if (result.size() != vals.length) { throw new IllegalArgumentException("Enum names are not disjoint set"); } return result; }
From source file:com.google.template.soy.jssrc.dsl.ArrayLiteral.java
static ArrayLiteral create(ImmutableList<? extends CodeChunk.WithValue> elements) { ImmutableSet.Builder<CodeChunk> builder = ImmutableSet.builder(); for (CodeChunk.WithValue element : elements) { builder.addAll(element.initialStatements()); }/*w ww . j ava2 s . co m*/ return new AutoValue_ArrayLiteral(builder.build(), elements); }
From source file:com.android.utils.ImmutableCollectors.java
public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() { return Collector.of(ImmutableSet::builder, ImmutableSet.Builder::add, (b1, b2) -> b1.addAll(b2.build()), ImmutableSet.Builder::build); }
From source file:com.google.devtools.build.android.ziputils.SplitZipFilters.java
/** * Returns a predicate that returns true for filenames contained in the given zip file. */// w w w.ja va 2 s . c o m public static Predicate<String> entriesIn(String filterZip) throws IOException { // Aggregate filenames into a set so Predicates.in is efficient ImmutableSet.Builder<String> filenames = ImmutableSet.builder(); @SuppressWarnings("resource") // ZipIn takes ownership but isn't Closable ZipIn zip = new ZipIn(new FileInputStream(filterZip).getChannel(), filterZip); for (DirectoryEntry entry : zip.centralDirectory().list()) { filenames.add(entry.getFilename()); } return Predicates.in(filenames.build()); }
From source file:com.isotrol.impe3.pms.core.obj.Builders.java
static <T> ImmutableSet.Builder<T> add(ImmutableSet.Builder<T> builder, T element) { if (builder == null) { builder = ImmutableSet.builder(); }// ww w . ja v a 2s. c om return builder.add(element); }
From source file:org.onlab.util.GuavaCollectors.java
/** * Returns a {@code Collector} that accumulates the input elements into a * new ImmutableSet.//from ww w.j a v a2s .c o m * * @param <T> type * @return a {@code Collector} which collects all the input elements into a * {@code ImmutableSet} */ public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() { return Collector.of(ImmutableSet.Builder<T>::new, ImmutableSet.Builder<T>::add, (s, r) -> s.addAll(r.build()), ImmutableSet.Builder<T>::build, Characteristics.UNORDERED); }
From source file:com.palantir.common.streams.MoreCollectors.java
public static <T> Collector<T, ?, Set<T>> toImmutableSet() { return Collector.of(ImmutableSet::<T>builder, ImmutableSet.Builder::<T>add, (left, right) -> left.addAll(right.build()), ImmutableSet.Builder::build, Collector.Characteristics.UNORDERED); }