List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:com.facebook.buck.features.ocaml.OcamlDepToolStep.java
@Override protected void addOptions(ImmutableSet.Builder<ProcessExecutor.Option> options) { // We need this else we get output with color codes which confuses parsing options.add(ProcessExecutor.Option.EXPECTING_STD_ERR); options.add(ProcessExecutor.Option.EXPECTING_STD_OUT); }
From source file:com.tngtech.archunit.junit.ArchRuleDeclaration.java
static Set<ArchRuleDeclaration<?>> toDeclarations(ArchRules rules, Class<?> testClass, Class<? extends Annotation> archTestAnnotationType, boolean forceIgnore) { ImmutableSet.Builder<ArchRuleDeclaration<?>> result = ImmutableSet.builder(); Class<?> definitionLocation = rules.getDefinitionLocation(); for (Field field : getAllFields(definitionLocation, withAnnotation(archTestAnnotationType))) { result.addAll(archRuleDeclarationsFrom(testClass, field, definitionLocation, archTestAnnotationType, forceIgnore));// w w w . j a va 2 s .c om } for (Method method : getAllMethods(definitionLocation, withAnnotation(archTestAnnotationType))) { result.add(ArchRuleDeclaration.from(testClass, method, definitionLocation, forceIgnore)); } return result.build(); }
From source file:com.facebook.buck.cxx.AbstractCxxPreprocessorInput.java
public static CxxPreprocessorInput concat(Iterable<CxxPreprocessorInput> inputs) { ImmutableMultimap.Builder<CxxSource.Type, String> preprocessorFlags = ImmutableMultimap.builder(); ImmutableList.Builder<CxxHeaders> headers = ImmutableList.builder(); ImmutableSet.Builder<FrameworkPath> frameworks = ImmutableSet.builder(); ImmutableSet.Builder<BuildTarget> rules = ImmutableSet.builder(); for (CxxPreprocessorInput input : inputs) { preprocessorFlags.putAll(input.getPreprocessorFlags()); headers.addAll(input.getIncludes()); frameworks.addAll(input.getFrameworks()); rules.addAll(input.getRules());/*from w w w . j a v a 2 s .c o m*/ } return CxxPreprocessorInput.of(preprocessorFlags.build(), headers.build(), frameworks.build(), rules.build()); }
From source file:org.eclipse.xtext.xtext.ParameterConfigHelper.java
public static Set<Parameter> getAssignedArguments(RuleCall ruleCall, Set<Parameter> contextParameters) { if (!ruleCall.getArguments().isEmpty()) { ConditionEvaluator evaluator = new ConditionEvaluator(contextParameters); ImmutableSet.Builder<Parameter> result = ImmutableSet.builder(); for (NamedArgument argument : ruleCall.getArguments()) { if (evaluator.evaluate(argument.getValue())) { result.add(argument.getParameter()); }/*from w w w.j a va2s . co m*/ } return result.build(); } else { return Collections.emptySet(); } }
From source file:com.facebook.buck.ocaml.OcamlUtil.java
static ImmutableSet<Path> getExtensionVariants(Path output, String... extensions) { String withoutExtension = stripExtension(output.toString()); ImmutableSet.Builder<Path> builder = ImmutableSet.builder(); for (String ext : extensions) { builder.add(Paths.get(withoutExtension + ext)); }// w w w .j a v a 2s . c o m return builder.build(); }
From source file:net.minecrell.box.config.FontShape.java
FontShape(MaterialData material, String... shape) { this.material = material; if (shape.length > 0) { checkArgument(HEIGHT == shape.length, "invalid shape size"); ImmutableSet.Builder<BoxPoint> points = ImmutableSet.<BoxPoint>builder(); for (int y = 0; y < shape.length; y++) { char[] line = shape[y].toCharArray(); checkArgument(WIDTH == line.length, "invalid shape size for " + name() + " at line " + y); for (int x = 0; x < line.length; x++) { if (!Character.isWhitespace(line[x])) { points.add(new BoxPoint(x, y)); }//from w ww . j av a 2s. com } } this.points = points.build(); } else { this.points = null; } }
From source file:com.facebook.buck.rust.RustLibraryArg.java
@Override public ImmutableCollection<BuildRule> getDeps(SourcePathRuleFinder ruleFinder) { ImmutableSet.Builder<BuildRule> deps = ImmutableSet.builder(); deps.addAll(ruleFinder.filterBuildRuleInputs(getInputs())); deps.addAll(this.deps); return deps.build(); }
From source file:org.obiba.magma.datasource.mongodb.MongoDBVariableEntityProvider.java
private Set<VariableEntity> loadEntities() { ImmutableSet.Builder<VariableEntity> builder = ImmutableSet.builder(); try (DBCursor cursor = table.getValueSetCollection().find(new BasicDBObject(), BasicDBObjectBuilder.start("_id", 1).get())) { while (cursor.hasNext()) { DBObject next = cursor.next(); builder.add(new VariableEntityBean(getEntityType(), next.get("_id").toString())); }// w ww .j a va 2s.co m } return builder.build(); }
From source file:com.google.errorprone.bugpatterns.apidiff.ApiDiff.java
/** Converts a {@link Diff} to a {@link ApiDiff}. */ public static ApiDiff fromProto(Diff diff) { ImmutableSet.Builder<String> unsupportedClasses = ImmutableSet.builder(); ImmutableSetMultimap.Builder<String, ClassMemberKey> unsupportedMembersByClass = ImmutableSetMultimap .builder();//from w ww . j a va2s . c o m for (ApiDiffProto.ClassDiff c : diff.getClassDiffList()) { switch (c.getDiffCase()) { case EVERYTHING_DIFF: unsupportedClasses.add(c.getEverythingDiff().getClassName()); break; case MEMBER_DIFF: ApiDiffProto.MemberDiff memberDiff = c.getMemberDiff(); for (ApiDiffProto.ClassMember member : memberDiff.getMemberList()) { unsupportedMembersByClass.put(memberDiff.getClassName(), ClassMemberKey.create(member.getIdentifier(), member.getMemberDescriptor())); } break; default: throw new AssertionError(c.getDiffCase()); } } return new AutoValue_ApiDiff(unsupportedClasses.build(), unsupportedMembersByClass.build()); }
From source file:com.google.cloud.dataflow.sdk.options.PipelineOptionsReflector.java
/** * Retrieve metadata for the full set of pipeline options visible within the type hierarchy * closure of the set of input interfaces. An option is "visible" if: * <p>// w w w.j a v a 2 s.c om * <ul> * <li>The option is defined within the interface hierarchy closure of the input * {@link PipelineOptions}.</li> * <li>The defining interface is not marked {@link Hidden}.</li> * </ul> */ static Set<PipelineOptionSpec> getOptionSpecs(Iterable<Class<? extends PipelineOptions>> optionsInterfaces) { ImmutableSet.Builder<PipelineOptionSpec> setBuilder = ImmutableSet.builder(); for (Class<? extends PipelineOptions> optionsInterface : optionsInterfaces) { setBuilder.addAll(getOptionSpecs(optionsInterface)); } return setBuilder.build(); }