List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:com.facebook.presto.sql.planner.optimizations.AggregationNodeUtils.java
public static Set<VariableReferenceExpression> extractUniqueVariables(AggregationNode.Aggregation aggregation, TypeProvider types) {//from w ww . ja va 2 s . c om ImmutableSet.Builder<VariableReferenceExpression> builder = ImmutableSet.builder(); aggregation.getArguments() .forEach(argument -> builder.addAll(SymbolsExtractor.extractAllVariable(argument, types))); aggregation.getFilter() .ifPresent(filter -> builder.addAll(SymbolsExtractor.extractAllVariable(filter, types))); aggregation.getOrderBy().ifPresent(orderingScheme -> builder.addAll(orderingScheme.getOrderBy())); return builder.build(); }
From source file:com.android.build.gradle.internal.dsl.AbiSplitOptions.java
/** * Returns the list of actual abi filters, each value of the collection is guaranteed to be non * null and of the possible API value.//from ww w . j a v a 2 s .c om * @param allFilters list of applicable filters {@see #getApplicationFilters} */ @NonNull public static ImmutableSet<String> getAbiFilters(@NonNull Set<String> allFilters) { ImmutableSet.Builder<String> filters = ImmutableSet.builder(); for (@Nullable String abi : allFilters) { // use object equality since abi can be null. //noinspection StringEquality if (abi != OutputFile.NO_FILTER) { filters.add(abi); } } return filters.build(); }
From source file:org.onosproject.cfg.impl.ConfigPropertyDefinitions.java
/** * Reads the specified input stream and creates from its contents a * set of property definitions.//from www . j ava2s. co m * * @param stream input stream * @return properties whose definitions are contained in the stream * @throws java.io.IOException if unable to read the stream */ public static Set<ConfigProperty> read(InputStream stream) throws IOException { ImmutableSet.Builder<ConfigProperty> builder = ImmutableSet.builder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(stream))) { String line; while ((line = br.readLine()) != null) { if (!line.isEmpty() && !line.startsWith(COMMENT)) { String[] f = line.split(SEP, 4); builder.add(defineProperty(f[0], Type.valueOf(f[1]), f[2], f[3])); } } } return builder.build(); }
From source file:org.obiba.onyx.jade.magma.WorkstationValueSetProvider.java
public Set<VariableEntity> getVariableEntities() { ImmutableSet.Builder<VariableEntity> builder = new ImmutableSet.Builder<VariableEntity>(); for (String instrumentTypeName : instrumentService.getInstrumentTypes().keySet()) { for (Instrument instrument : instrumentService.getInstruments(instrumentTypeName)) { String workstationName = instrument.getWorkstation(); if (workstationName != null) { builder.add(new VariableEntityBean(WORKSTATION, workstationName)); }/*from w w w . ja v a 2 s .co m*/ } } return builder.build(); }
From source file:org.obiba.opal.web.magma.ParticipantsResource.java
@GET @Path("/count") @NoAuthorization//ww w . j ava 2 s . c om public Response getParticipantCount() { Set<Datasource> datasources = MagmaEngine.get().getDatasources(); ImmutableSet.Builder<VariableEntity> participants = ImmutableSet.builder(); for (Datasource ds : datasources) { for (ValueTable table : Iterables.filter(ds.getValueTables(), ParticipantEntityTypePredicate.INSTANCE)) { participants.addAll(table.getVariableEntities()); } } return Response.ok(String.valueOf(participants.build().size())).build(); }
From source file:com.google.api.codegen.transformer.py.PythonSampleOutputImportTransformer.java
@Override public ImmutableList<ImportFileView> generateOutputImports(MethodContext context, List<OutputView> outputViews) { ImmutableSet.Builder<ImportFileView> imports = ImmutableSet.builder(); addImports(imports, context, outputViews); return imports.build().asList(); }
From source file:org.gradle.api.plugins.buildcomparison.outcome.internal.archive.entry.FileToArchiveEntrySetTransformer.java
public Set<ArchiveEntry> transform(File archiveFile) { FileInputStream fileInputStream; try {// w w w. j av a 2 s . c om fileInputStream = new FileInputStream(archiveFile); } catch (FileNotFoundException e) { throw new UncheckedIOException(e); } ImmutableSet.Builder<ArchiveEntry> allEntries = ImmutableSet.builder(); walk(fileInputStream, allEntries, ImmutableList.<String>of()); return allEntries.build(); }
From source file:com.facebook.buck.android.ClassNameFilter.java
/** * Convenience factory to produce a filter from a very simple pattern language. * * <p>patterns are substrings by default, but {@code ^} at the start or end of a pattern * anchors it to the start or end of the class name. * * @param patterns Patterns to include in the filter. * @return A new filter./*from w w w . j a v a2 s . c o m*/ */ public static ClassNameFilter fromConfiguration(Iterable<String> patterns) { ImmutableList.Builder<String> prefixes = ImmutableList.builder(); ImmutableList.Builder<String> suffixes = ImmutableList.builder(); ImmutableList.Builder<String> substrings = ImmutableList.builder(); ImmutableSet.Builder<String> exactMatches = ImmutableSet.builder(); for (String pattern : patterns) { boolean isPrefix = pattern.charAt(0) == '^'; boolean isSuffix = pattern.charAt(pattern.length() - 1) == '^'; if (isPrefix && isSuffix) { exactMatches.add(pattern.substring(1, pattern.length() - 1)); } else if (isPrefix) { prefixes.add(pattern.substring(1)); } else if (isSuffix) { suffixes.add(pattern.substring(0, pattern.length() - 1)); } else { substrings.add(pattern); } } return new ClassNameFilter(prefixes.build(), suffixes.build(), substrings.build(), exactMatches.build()); }
From source file:com.cynnyx.auto.value.map.MapMethod.java
static Set<ExecutableElement> filteredAbstractMethods(AutoValueExtension.Context context) { TypeElement type = context.autoValueClass(); // check that the class contains method: public abstract Map<String, Object> toMap() or Map toMap() ParameterizedTypeName targetReturnType = ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class), TypeName.OBJECT); ImmutableSet.Builder<ExecutableElement> foundMethods = ImmutableSet.builder(); for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) { if (method.getModifiers().contains(Modifier.ABSTRACT) && method.getModifiers().contains(Modifier.PUBLIC) && method.getSimpleName().toString().equals(METHOD_NAME) && method.getParameters().size() == 0) { TypeMirror rType = method.getReturnType(); TypeName returnType = TypeName.get(rType); if (returnType.equals(targetReturnType)) { foundMethods.add(method); break; }/*from w ww . j ava 2s.c om*/ if (returnType.equals(targetReturnType.rawType)) { if (returnType instanceof ParameterizedTypeName) { Messager messager = context.processingEnvironment().getMessager(); ParameterizedTypeName paramReturnType = (ParameterizedTypeName) returnType; TypeName argument = paramReturnType.typeArguments.get(0); messager.printMessage(Diagnostic.Kind.WARNING, String.format( "Found public static method returning Map<%s> instead of Map<String,Object>", argument)); } else { foundMethods.add(method); } } } } return foundMethods.build(); }
From source file:com.google.devtools.moe.client.tools.CodebaseDiffer.java
/** * Diff two {@link Codebase} instances with a {@link FileDiffer}. *///from ww w.ja v a2s .c om public CodebaseDifference diffCodebases(Codebase codebase1, Codebase codebase2) { Set<String> filenames = Sets.union(codebase1.getRelativeFilenames(), codebase2.getRelativeFilenames()); ImmutableSet.Builder<FileDifference> fileDiffs = ImmutableSet.builder(); for (String filename : filenames) { FileDifference fileDiff = differ.diffFiles(filename, codebase1.getFile(filename), codebase2.getFile(filename)); if (fileDiff.isDifferent()) { fileDiffs.add(fileDiff); } } return new CodebaseDifference(codebase1, codebase2, fileDiffs.build()); }