List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.spectralogic.ds3autogen.converters.ResponseTypeConverter.java
/** * Gets a list of response Component Types and original type names that are being * converted into new models that are within the Ds3Requests list. *///from w w w. j a va2 s .c o m protected static ImmutableSet<EncapsulatingTypeNames> getResponseComponentTypesFromRequests( final ImmutableList<Ds3Request> requests) { if (isEmpty(requests)) { LOG.debug("No requests for model generation of response component types"); return ImmutableSet.of(); } final ImmutableSet.Builder<EncapsulatingTypeNames> builder = ImmutableSet.builder(); for (final Ds3Request request : requests) { builder.addAll(getResponseComponentTypesFromResponseCodes(request.getDs3ResponseCodes())); } return builder.build(); }
From source file:com.spotify.heroic.metric.QueryResult.java
/** * Collect result parts into a complete result. * * @param range The range which the result represents. * @return A complete QueryResult.//from w w w.j a va 2 s. c om */ public static Collector<QueryResultPart, QueryResult> collectParts(final QueryTrace.Identifier what, final DateRange range, final AggregationCombiner combiner, final OptionalLimit groupLimit) { final QueryTrace.NamedWatch w = QueryTrace.watch(what); return parts -> { final List<List<ShardedResultGroup>> all = new ArrayList<>(); final List<RequestError> errors = new ArrayList<>(); final ImmutableList.Builder<QueryTrace> queryTraces = ImmutableList.builder(); final ImmutableSet.Builder<ResultLimit> limits = ImmutableSet.builder(); long preAggregationSampleSize = 0; for (final QueryResultPart part : parts) { errors.addAll(part.getErrors()); queryTraces.add(part.getQueryTrace()); limits.addAll(part.getLimits().getLimits()); preAggregationSampleSize += part.getPreAggregationSampleSize(); if (part.isEmpty()) { continue; } all.add(part.getGroups()); } final List<ShardedResultGroup> groups = combiner.combine(all); final QueryTrace trace = w.end(queryTraces.build()); if (groupLimit.isGreaterOrEqual(groups.size())) { limits.add(ResultLimit.GROUP); } return new QueryResult(range, groupLimit.limitList(groups), errors, trace, new ResultLimits(limits.build()), preAggregationSampleSize, Optional.empty()); }; }
From source file:ca.cutterslade.match.scheduler.Team.java
static ImmutableSet<Team> forNames(Set<String> names, Set<Tier> tiers, int tierSize) { ImmutableSet.Builder<Team> teams = ImmutableSet.builder(); Iterator<String> tit = names.iterator(); for (Tier t : tiers) { List<Team> tierTeams = Lists.newArrayList(); while (tit.hasNext() && tierSize > tierTeams.size()) tierTeams.add(new Team(tit.next(), t)); teams.addAll(tierTeams); if (!tit.hasNext()) break; }//from w ww. j a v a 2s. c o m return teams.build(); }
From source file:com.spectralogic.ds3autogen.converters.ResponseTypeConverter.java
/** * Gets a list of response Component Types and original type names that are being converted * into new models that are within the Ds3ResponseCodes list. *///from w w w . ja v a2 s .co m protected static ImmutableSet<EncapsulatingTypeNames> getResponseComponentTypesFromResponseCodes( final ImmutableList<Ds3ResponseCode> responseCodes) { if (isEmpty(responseCodes)) { LOG.debug("No response codes for model generation of response component types"); return ImmutableSet.of(); } final ImmutableSet.Builder<EncapsulatingTypeNames> builder = ImmutableSet.builder(); for (final Ds3ResponseCode responseCode : responseCodes) { builder.addAll(getResponseTypesToUpdateFromResponseTypes(responseCode.getDs3ResponseTypes())); } return builder.build(); }
From source file:com.google.idea.blaze.cpp.BlazeResolveConfigurationTemporaryBase.java
@Nullable public static BlazeResolveConfiguration createConfigurationForTarget(Project project, WorkspacePathResolver workspacePathResolver, ImmutableMap<File, VirtualFile> headerRoots, TargetIdeInfo target, CToolchainIdeInfo toolchainIdeInfo, File compilerWrapper) { CIdeInfo cIdeInfo = target.cIdeInfo; if (cIdeInfo == null) { return null; }//from w w w .j ava2 s . co m ImmutableSet.Builder<ExecutionRootPath> systemIncludesBuilder = ImmutableSet.builder(); systemIncludesBuilder.addAll(cIdeInfo.transitiveSystemIncludeDirectories); systemIncludesBuilder.addAll(toolchainIdeInfo.builtInIncludeDirectories); systemIncludesBuilder.addAll(toolchainIdeInfo.unfilteredToolchainSystemIncludes); ImmutableSet.Builder<ExecutionRootPath> userIncludesBuilder = ImmutableSet.builder(); userIncludesBuilder.addAll(cIdeInfo.transitiveIncludeDirectories); ImmutableSet.Builder<ExecutionRootPath> userQuoteIncludesBuilder = ImmutableSet.builder(); userQuoteIncludesBuilder.addAll(cIdeInfo.transitiveQuoteIncludeDirectories); ImmutableList.Builder<String> cFlagsBuilder = ImmutableList.builder(); cFlagsBuilder.addAll(toolchainIdeInfo.baseCompilerOptions); cFlagsBuilder.addAll(toolchainIdeInfo.cCompilerOptions); cFlagsBuilder.addAll(toolchainIdeInfo.unfilteredCompilerOptions); ImmutableList.Builder<String> cppFlagsBuilder = ImmutableList.builder(); cppFlagsBuilder.addAll(toolchainIdeInfo.baseCompilerOptions); cppFlagsBuilder.addAll(toolchainIdeInfo.cppCompilerOptions); cppFlagsBuilder.addAll(toolchainIdeInfo.unfilteredCompilerOptions); ImmutableMap<String, String> features = ImmutableMap.of(); return new BlazeResolveConfiguration(project, workspacePathResolver, headerRoots, target.key, systemIncludesBuilder.build(), systemIncludesBuilder.build(), userQuoteIncludesBuilder.build(), userIncludesBuilder.build(), userIncludesBuilder.build(), cIdeInfo.transitiveDefines, features, compilerWrapper, compilerWrapper, cFlagsBuilder.build(), cppFlagsBuilder.build()); }
From source file:edu.mit.streamjit.util.ReflectionUtils.java
public static <T> ImmutableSet<Class<?>> getAllSupertypes(Class<T> klass) { ImmutableSet.Builder<Class<?>> builder = ImmutableSet.builder(); builder.add(klass);/*from w ww .j av a 2 s.co m*/ for (Class<?> c : klass.getInterfaces()) builder.add(c); if (klass.getSuperclass() != null) builder.addAll(getAllSupertypes(klass.getSuperclass())); return builder.build(); }
From source file:com.spectralogic.ds3autogen.utils.ConverterUtil.java
/** * Gets a set of type names used within a list of Ds3ResponseCodes *///from w ww .j a v a 2s.com protected static ImmutableSet<String> getUsedTypesFromResponseCodes( final ImmutableList<Ds3ResponseCode> responseCodes) { if (isEmpty(responseCodes)) { return ImmutableSet.of(); } final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (final Ds3ResponseCode responseCode : responseCodes) { if (hasContent(responseCode.getDs3ResponseTypes())) { builder.addAll(getUsedTypesFromResponseTypes(responseCode.getDs3ResponseTypes())); } } return builder.build(); }
From source file:com.google.template.soy.types.aggregate.UnionType.java
/** * Create a set containing all of the types contained in the input collection. * If any of the members of the input collection are unions, add the * individual members to the result union, thus "flattening" the union. * @param members The input types.// w ww . j a v a 2s . c o m * @return The set of all types in the input collection. */ private static ImmutableSet<SoyType> flatten(Collection<SoyType> members) { ImmutableSet.Builder<SoyType> builder = ImmutableSet.builder(); for (SoyType type : members) { if (type.getKind() == Kind.UNKNOWN) { return ImmutableSet.of(type); } if (type.getKind() == Kind.UNION) { builder.addAll(((UnionType) type).members); } else { builder.add(type); } } return builder.build(); }
From source file:com.spotify.heroic.metric.FullQuery.java
public static Collector<FullQuery, FullQuery> collect(final QueryTrace.Identifier what) { final QueryTrace.NamedWatch w = QueryTrace.watch(what); return results -> { final ImmutableList.Builder<QueryTrace> traces = ImmutableList.builder(); final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); final ImmutableList.Builder<ResultGroup> groups = ImmutableList.builder(); Statistics statistics = Statistics.empty(); final ImmutableSet.Builder<ResultLimit> limits = ImmutableSet.builder(); for (final FullQuery r : results) { traces.add(r.trace);/* w w w .ja v a 2s. c o m*/ errors.addAll(r.errors); groups.addAll(r.groups); statistics = statistics.merge(r.statistics); limits.addAll(r.limits.getLimits()); } return new FullQuery(w.end(traces.build()), errors.build(), groups.build(), statistics, new ResultLimits(limits.build()), Optional.empty()); }; }
From source file:com.facebook.buck.haskell.HaskellDescriptionUtils.java
/** * @return parse-time deps needed by Haskell descriptions. *///from ww w .j a v a2 s . co m public static Iterable<BuildTarget> getParseTimeDeps(HaskellConfig haskellConfig, Iterable<CxxPlatform> cxxPlatforms) { ImmutableSet.Builder<BuildTarget> deps = ImmutableSet.builder(); // Since this description generates haskell link rules, make sure the parsed includes any // of the linkers parse time deps. deps.addAll(haskellConfig.getLinker().getParseTimeDeps()); // Since this description generates haskell compile rules, make sure the parsed includes any // of the compilers parse time deps. deps.addAll(haskellConfig.getCompiler().getParseTimeDeps()); // We use the C/C++ linker's Linker object to find out how to pass in the soname, so just add // all C/C++ platform parse time deps. deps.addAll(CxxPlatforms.getParseTimeDeps(cxxPlatforms)); return deps.build(); }