List of usage examples for com.google.common.collect ImmutableSet.Builder add
boolean add(E e);
From source file:crud.http.util.FailedResponseOperator.java
public static FailedResponseOperator fromResponseStatuses(final Iterable<Response.Status> statuses) { final ImmutableSet.Builder<Integer> statusCodes = new ImmutableSet.Builder<>(); for (final Response.Status status : statuses) { statusCodes.add(status.getStatusCode()); }/*from w w w. j a v a 2 s. co m*/ // Don't delegate to fromStatusCodes(): it does extraneous checking return new FailedResponseOperator(statusCodes.build()); }
From source file:com.calclab.emite.xep.disco.DiscoveryManagerImpl.java
private static final ImmutableSet<Identity> parseIdentities(final XMLPacket query) { final ImmutableSet.Builder<Identity> builder = ImmutableSet.builder(); for (final XMLPacket child : query.getChildren("identity")) { builder.add(new Identity(child.getAttribute("category"), child.getAttribute("type"), child.getAttribute("name"))); }/*from w ww.j a v a 2s . co m*/ return builder.build(); }
From source file:com.tngtech.archunit.core.importer.Locations.java
/** * @return All classes that can be found within the classpath. Note that ArchUnit does not distinguish between * the classpath and the modulepath, thus for Java >= 9 all locations of class files from the * modulepath with be returned as well.//w w w .jav a2s.com */ @PublicAPI(usage = ACCESS) public static Set<Location> inClassPath() { ImmutableSet.Builder<Location> result = ImmutableSet.builder(); for (URL url : locationResolver.get().resolveClassPath()) { result.add(Location.of(url)); } return result.build(); }
From source file:edu.umn.msi.tropix.proteomics.itraqquantitation.impl.ScanIndex.java
private static final ImmutableSet<String> buildAlternativeNames(final Iterable<String> alternativeNames) { final ImmutableSet.Builder<String> alternativeNamesBuilder = ImmutableSet.builder(); for (final String alternativeName : alternativeNames) { alternativeNamesBuilder.add(alternativeName); final Matcher matcher = MULTIFILE_PATTERN.matcher(alternativeName); if (matcher.matches()) { alternativeNamesBuilder.add(matcher.group(1)); }/* w w w .j a v a 2 s .co m*/ } return alternativeNamesBuilder.build(); }
From source file:io.ytcode.reflect.Reflect.java
public static ImmutableSet<Field> fields(Class<?> c, Predicate<Field> p) { checkNotNull(c);/*from w w w . j a v a2 s .co m*/ checkNotNull(p); ImmutableSet.Builder<Field> b = ImmutableSet.builder(); for (Field field : c.getDeclaredFields()) { if (p.apply(field)) { b.add(field); } } for (Class<?> cls : superTypes(c)) { for (Field field : cls.getDeclaredFields()) { if (p.apply(field)) { b.add(field); } } } return b.build(); }
From source file:com.tngtech.archunit.core.importer.Locations.java
/** * All {@link Location locations} in the classpath that match the supplied package. * * @param pkg the package to look for within the classpath * @return {@link Location Locations} of all paths that match the supplied package *//*from w w w .j a v a2s . co m*/ @PublicAPI(usage = ACCESS) public static Set<Location> ofPackage(String pkg) { ImmutableSet.Builder<Location> result = ImmutableSet.builder(); for (Location location : getLocationsOf(asResourceName(pkg))) { result.add(location); } return result.build(); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3ElementDiffSimplePrinter.java
/** * Gets the union of names of all params within two {@link ImmutableList} of {@link Ds3Annotation} *//*ww w. j a va 2 s. com*/ private static ImmutableSet<String> getAnnotationNameUnion(final ImmutableList<Ds3Annotation> oldAnnotations, final ImmutableList<Ds3Annotation> newAnnotations) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (hasContent(oldAnnotations)) { oldAnnotations.forEach(annotation -> builder.add(annotation.getName())); } if (hasContent(newAnnotations)) { newAnnotations.forEach(annotation -> builder.add(annotation.getName())); } return builder.build(); }
From source file:crud.http.util.FailedResponseOperator.java
public static FailedResponseOperator fromClientResponseStatuses( final Iterable<ClientResponse.Status> statuses) { final ImmutableSet.Builder<Integer> statusCodes = new ImmutableSet.Builder<>(); for (final ClientResponse.Status status : statuses) { statusCodes.add(status.getStatusCode()); }//from w w w .j ava2s .c o m // Don't delegate to fromStatusCodes(): it does extraneous checking return new FailedResponseOperator(statusCodes.build()); }
From source file:com.kolich.curacao.mappers.request.matchers.DefaultCuracaoRegexPathMatcher.java
/** * Given a regex as a String, returns an {@link ImmutableSet} representing * the named capture groups in the regex. For example, <tt>^(?<foo>\w+)</tt> * would return an {@link ImmutableSet} with a single entry "foo" * corresponding to the named capture group "foo". *///from w ww . ja v a 2s. c om @Nonnull private static final ImmutableSet<String> getNamedGroups(final String regex) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); final Matcher m = NAMED_GROUPS_REGEX.matcher(regex); while (m.find()) { builder.add(m.group(1)); } return builder.build(); // Immutable }
From source file:google.registry.model.ofy.CommitLogBucket.java
/** Returns the set of all loaded commit log buckets, filling in missing buckets with new ones. */ public static ImmutableSet<CommitLogBucket> loadAllBuckets() { ofy().load().keys(getAllBucketKeys()); // Load all buckets into session cache at once. ImmutableSet.Builder<CommitLogBucket> allBuckets = new ImmutableSet.Builder<>(); for (Key<CommitLogBucket> key : getAllBucketKeys()) { allBuckets.add(loadBucket(key)); }//from w w w .j a v a 2 s . co m return allBuckets.build(); }