List of usage examples for com.google.common.collect ImmutableSet.Builder add
boolean add(E e);
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;//ww w. ja v a 2 s . co m while (matcher.find(pos)) { builder.add(matcher.group(1)); pos = matcher.end(); } return builder.build(); }
From source file:org.apache.aurora.scheduler.base.JobKeys.java
/** * Attempt to extract job keys from the given query if it is job scoped. * * @param query Query to extract the keys from. * @return A present if keys can be extracted, absent otherwise. *///from w w w . j a v a2 s . c o m public static Optional<Set<IJobKey>> from(Query.Builder query) { if (Query.isJobScoped(query)) { ITaskQuery taskQuery = query.get(); ImmutableSet.Builder<IJobKey> builder = ImmutableSet.builder(); if (taskQuery.isSetJobName()) { builder.add(from(taskQuery.getRole(), taskQuery.getEnvironment(), taskQuery.getJobName())); } builder.addAll(taskQuery.getJobKeys()); return Optional.of(assertValid(builder.build())); } else { return Optional.absent(); } }
From source file:org.sosy_lab.cpachecker.cpa.programcounter.ProgramCounterState.java
public static AbstractState getStateForValues(Iterable<BigInteger> pValues) { ImmutableSet.Builder<BigInteger> builder = ImmutableSet.builder(); for (BigInteger value : pValues) { builder.add(value); }//from ww w.j a v a 2 s. c o m return new ProgramCounterState(builder.build()); }
From source file:com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils.java
public static ImmutableSet<Integer> createExpectedSet(final int[] expectedStatuses) { final ImmutableSet.Builder<Integer> setBuilder = ImmutableSet.builder(); for (final int status : expectedStatuses) { setBuilder.add(status); }/*from w w w.java2s . co m*/ return setBuilder.build(); }
From source file:com.google.publicalerts.cap.XercesCapExceptionMapper.java
private static Set<String> buildValidTagSet() { ImmutableSet.Builder<String> ret = ImmutableSet.builder(); ret.add("alert"); for (Descriptor d : Cap.getDescriptor().getMessageTypes()) { for (FieldDescriptor fd : d.getFields()) { ret.add(CapUtil.javaCase(fd.getName())); }// ww w .ja va 2 s . com } return ret.build(); }
From source file:com.google.template.soy.soyparse.ParseErrors.java
static void reportSoyFileParseException(ErrorReporter reporter, String filePath, ParseException e) { // currentToken is the 'last successfully consumed token', but the error is usually due to the // first unsuccessful token. use that for the source location Token errorToken = e.currentToken;//from www. j a va 2s . c om if (errorToken.next != null) { errorToken = errorToken.next; } ImmutableSet.Builder<String> expectedTokenImages = ImmutableSet.builder(); for (int[] expected : e.expectedTokenSequences) { // We only display the first token expectedTokenImages.add(getSoyFileParserTokenDisplayName(expected[0])); } reporter.report(Tokens.createSrcLoc(filePath, errorToken), SoyError.of("{0}"), formatParseExceptionDetails(errorToken.image, expectedTokenImages.build().asList())); }
From source file:com.tngtech.archunit.core.importer.Locations.java
/** * Directly converts the passed URLs to {@link Location locations}. URLs can be of class files * as well as directories. They can also be JAR URLs of class files * (e.g. <code>jar:file:///some.jar!/some/Example.class</code>) or folders within JAR files. * * @param urls URLs to directly convert to {@link Location locations} * @return {@link Location Locations} representing the passed URLs *///from w ww . j av a 2 s . co m @PublicAPI(usage = ACCESS) public static Set<Location> of(Iterable<URL> urls) { ImmutableSet.Builder<Location> result = ImmutableSet.builder(); for (URL url : urls) { result.add(Location.of(url)); } return result.build(); }
From source file:com.spectralogic.ds3contractcomparator.Ds3ApiSpecComparatorImpl.java
/** * Gets the union of all {@link Ds3Request} names in both lists */// ww w.ja v a 2s . co m static ImmutableSet<String> getRequestNameUnion(final ImmutableList<Ds3Request> oldRequests, final ImmutableList<Ds3Request> newRequests) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (ConverterUtil.hasContent(oldRequests)) { oldRequests.forEach(request -> builder.add(request.getName())); } if (ConverterUtil.hasContent(newRequests)) { newRequests.forEach(request -> builder.add(request.getName())); } return builder.build(); }
From source file:com.google.appengine.tools.cloudstorage.GcsServiceFactory.java
static RawGcsService createRawGcsService(Map<String, String> headers) { ImmutableSet.Builder<HTTPHeader> builder = ImmutableSet.builder(); if (headers != null) { for (Map.Entry<String, String> header : headers.entrySet()) { builder.add(new HTTPHeader(header.getKey(), header.getValue())); }//from w w w .j ava 2s .c om } RawGcsService rawGcsService; Value location = SystemProperty.environment.value(); if (location == SystemProperty.Environment.Value.Production || hasCustomAccessTokenProvider()) { rawGcsService = OauthRawGcsServiceFactory.createOauthRawGcsService(builder.build()); } else if (location == SystemProperty.Environment.Value.Development) { rawGcsService = LocalRawGcsServiceFactory.createLocalRawGcsService(); } else { Delegate<?> delegate = ApiProxy.getDelegate(); if (delegate == null || delegate.getClass().getName().startsWith("com.google.appengine.tools.development")) { rawGcsService = LocalRawGcsServiceFactory.createLocalRawGcsService(); } else { rawGcsService = OauthRawGcsServiceFactory.createOauthRawGcsService(builder.build()); } } return rawGcsService; }
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.// w w w . ja v a 2 s . 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(); } }