List of usage examples for com.google.common.collect ImmutableSortedSet builder
@Deprecated public static <E> ImmutableSortedSet.Builder<E> builder()
From source file:com.facebook.buck.rules.DescribedRuleBuilder.java
private void addTargetIfPresent(ImmutableSortedSet.Builder<BuildTarget> builder, BuildRuleFactoryParams params, String param) throws NoSuchBuildTargetException { if (isPossiblyATarget(param)) { builder.add(params.resolveBuildTarget(param)); }//from w w w.ja v a 2 s .com }
From source file:eu.eidas.auth.commons.attribute.AttributeSetPropertiesConverter.java
@Nonnull private static ImmutableSortedSet<AttributeDefinition<?>> toAttributeSetFromProperties( @Nonnull Map<?, ?> properties) { ImmutableSortedSet.Builder<AttributeDefinition<?>> setBuilder = new ImmutableSortedSet.Builder<AttributeDefinition<?>>( Ordering.natural());/* ww w .j a v a 2 s. com*/ for (Map.Entry<?, ?> entry : properties.entrySet()) { String key = (String) entry.getKey(); if (Suffix.NAME_URI.matches(key)) { String id = Suffix.NAME_URI.extractKeyPrefix(key); String fullName = getMandatoryString(properties, Suffix.NAME_URI, id); String friendlyName = getMandatoryString(properties, Suffix.FRIENDLY_NAME, id); boolean required = getOptionalFlag(properties, Suffix.REQUIRED, id); boolean transliterationMandatory = getOptionalFlag(properties, Suffix.TRANSLITERATION_MANDATORY, id); boolean uniqueIdentifier = getOptionalFlag(properties, Suffix.UNIQUE_IDENTIFIER, id); String typeStr = getMandatoryString(properties, Suffix.PERSON_TYPE, id); PersonType personType = PersonType.fromString(typeStr); if (null == personType) { throw new IllegalArgumentException("Entry \"" + Suffix.PERSON_TYPE.computeEntry(id) + "\" has an illegal value \"" + typeStr + "\""); } String xmlNamespaceUri = getMandatoryString(properties, Suffix.XML_TYPE_NAMESPACE_URI, id); String localPart = getMandatoryString(properties, Suffix.XML_TYPE_LOCAL_PART, id); String xmlNamespacePrefix = getMandatoryString(properties, Suffix.XML_TYPE_NAMESPACE_PREFIX, id); String attributeValueMarshaller = getMandatoryString(properties, Suffix.ATTRIBUTE_VALUE_MARSHALLER, id); AttributeDefinition.Builder<?> builder = AttributeDefinition.builder(); builder.nameUri(fullName); builder.friendlyName(friendlyName); builder.personType(personType); builder.required(required); builder.transliterationMandatory(transliterationMandatory); builder.uniqueIdentifier(uniqueIdentifier); builder.xmlType(xmlNamespaceUri, localPart, xmlNamespacePrefix); builder.attributeValueMarshaller(attributeValueMarshaller); setBuilder.add(builder.build()); } } return setBuilder.build(); }
From source file:com.facebook.buck.rules.modern.ModernBuildRule.java
/** Computes the inputs of the build rule. */ public ImmutableSortedSet<SourcePath> computeInputs() { ImmutableSortedSet.Builder<SourcePath> depsBuilder = ImmutableSortedSet.naturalOrder(); new InputsMapBuilder().getInputs(getBuildable()).forAllData(data -> depsBuilder.addAll(data.getPaths())); return depsBuilder.build(); }
From source file:com.facebook.buck.cli.BuckQueryEnvironment.java
public ImmutableSet<QueryTarget> getTargetsFromBuildTargetsContainer( Iterable<? extends HasBuildTarget> buildTargetsContainer) { ImmutableSortedSet.Builder<QueryTarget> builder = ImmutableSortedSet.naturalOrder(); for (HasBuildTarget hasBuildTarget : buildTargetsContainer) { builder.add(getOrCreateQueryBuildTarget(hasBuildTarget.getBuildTarget())); }/*from w ww .j av a 2 s . co m*/ return builder.build(); }
From source file:com.facebook.buck.thrift.ThriftLibraryDescription.java
/** * Downcast the given deps to {@link ThriftLibrary} rules, throwing an error if we see an * unexpected type.//from w w w. j av a 2 s . c o m */ private static ImmutableSortedSet<ThriftLibrary> resolveThriftDeps(BuildTarget target, Iterable<BuildRule> deps) { ImmutableSortedSet.Builder<ThriftLibrary> libDepsBuilder = ImmutableSortedSet.naturalOrder(); for (BuildRule dep : deps) { if (!(dep instanceof ThriftLibrary)) { throw new HumanReadableException("%s: parameter \"deps\": \"%s\" (%s) is not a thrift_library", target, dep.getBuildTarget(), dep.getType()); } libDepsBuilder.add((ThriftLibrary) dep); } return libDepsBuilder.build(); }
From source file:com.zulily.omicron.scheduling.Job.java
public ImmutableSortedSet<TaskLogEntry> filterLog(final Set<TaskStatus> statusFilter) { checkNotNull(statusFilter, "statusFilter"); checkArgument(!statusFilter.isEmpty(), "empty filter"); ImmutableSortedSet.Builder<TaskLogEntry> result = ImmutableSortedSet.naturalOrder(); reentrantLock.lock();//w ww. j a va 2 s . co m try { taskLog.stream().filter(entry -> statusFilter.contains(entry.getTaskStatus())).forEach(result::add); } finally { reentrantLock.unlock(); } return result.build(); }
From source file:com.facebook.buck.d.DDescriptionUtils.java
/** * Ensures that a DCompileBuildRule exists for the given target, creating a DCompileBuildRule * if neccesary./*from www . j a v a 2 s. com*/ * @param baseParams build parameters for the rule * @param buildRuleResolver BuildRuleResolver the rule should be in * @param sourcePathResolver used to resolve source paths * @param src the source file to be compiled * @param compilerFlags flags to pass to the compiler * @param compileTarget the target the rule should be for * @param dBuckConfig the Buck configuration for D * @return the build rule */ public static DCompileBuildRule requireBuildRule(BuildTarget compileTarget, BuildRuleParams baseParams, BuildRuleResolver buildRuleResolver, SourcePathResolver sourcePathResolver, SourcePathRuleFinder ruleFinder, DBuckConfig dBuckConfig, ImmutableList<String> compilerFlags, String name, SourcePath src, DIncludes includes) throws NoSuchBuildTargetException { Optional<BuildRule> existingRule = buildRuleResolver.getRuleOptional(compileTarget); if (existingRule.isPresent()) { return (DCompileBuildRule) existingRule.get(); } else { Tool compiler = dBuckConfig.getDCompiler(); Map<BuildTarget, DIncludes> transitiveIncludes = new TreeMap<>(); transitiveIncludes.put(baseParams.getBuildTarget(), includes); for (Map.Entry<BuildTarget, DLibrary> library : getTransitiveDLibraryRules(baseParams.getDeps()) .entrySet()) { transitiveIncludes.put(library.getKey(), library.getValue().getIncludes()); } ImmutableSortedSet.Builder<BuildRule> depsBuilder = ImmutableSortedSet.naturalOrder(); depsBuilder.addAll(compiler.getDeps(ruleFinder)); depsBuilder.addAll(ruleFinder.filterBuildRuleInputs(src)); for (DIncludes dIncludes : transitiveIncludes.values()) { depsBuilder.addAll(dIncludes.getDeps(ruleFinder)); } ImmutableSortedSet<BuildRule> deps = depsBuilder.build(); return buildRuleResolver .addToIndex( new DCompileBuildRule( baseParams.copyWithChanges(compileTarget, Suppliers.ofInstance(deps), Suppliers.ofInstance(ImmutableSortedSet.of())), sourcePathResolver, compiler, ImmutableList.<String>builder().addAll(dBuckConfig.getBaseCompilerFlags()) .addAll(compilerFlags).build(), name, ImmutableSortedSet.of(src), ImmutableList.copyOf(transitiveIncludes.values()))); } }
From source file:edu.mit.streamjit.impl.compiler2.ActorGroup.java
/** * Returns the physical indices written to the given storage during the * given group iteration.//from www .j a va2s . c om * @param s the storage being written to * @param iteration the group iteration number * @return the physical indices written */ public ImmutableSortedSet<Integer> writes(Storage s, int iteration) { ImmutableSortedSet.Builder<Integer> builder = ImmutableSortedSet.naturalOrder(); for (Actor a : actors()) builder.addAll( a.writes(s, Range.closedOpen(iteration * schedule.get(a), (iteration + 1) * schedule.get(a)))); return builder.build(); }
From source file:com.facebook.buck.cxx.PreInclude.java
private ImmutableSortedSet<BuildRule> getPreprocessDeps(CxxPlatform cxxPlatform, ActionGraphBuilder graphBuilder, SourcePathRuleFinder ruleFinder) { ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.naturalOrder(); for (CxxPreprocessorInput input : getCxxPreprocessorInputs(cxxPlatform, graphBuilder)) { builder.addAll(input.getDeps(graphBuilder, ruleFinder)); }//w w w . j a va 2s . c o m for (CxxHeaders cxxHeaders : getIncludes(cxxPlatform, graphBuilder)) { cxxHeaders.getDeps(ruleFinder).forEachOrdered(builder::add); } for (FrameworkPath frameworkPath : getFrameworks(cxxPlatform, graphBuilder)) { builder.addAll(frameworkPath.getDeps(ruleFinder)); } builder.addAll(getBuildDeps()); builder.addAll(getExportedDeps()); return builder.build(); }
From source file:com.google.devtools.build.lib.rules.java.ProguardHelper.java
/** * Retrieves the full set of proguard specs that should be applied to this binary, including the * specs passed in, if Proguard should run on the given rule. {@link #createProguardAction} * relies on this method returning an empty list if the given rule doesn't declare specs in * --java_optimization_mode=legacy./*from w w w.j av a 2 s . c om*/ * * <p>If Proguard shouldn't be applied, or the legacy link mode is used and there are no * proguard_specs on this rule, an empty list will be returned, regardless of any given specs or * specs from dependencies. * {@link com.google.devtools.build.lib.rules.android.AndroidBinary#createAndroidBinary} relies on * that behavior. */ public static ImmutableList<Artifact> collectTransitiveProguardSpecs(RuleContext ruleContext, Iterable<Artifact> specsToInclude) { JavaOptimizationMode optMode = getJavaOptimizationMode(ruleContext); if (optMode == JavaOptimizationMode.NOOP) { return ImmutableList.of(); } ImmutableList<Artifact> proguardSpecs = ruleContext.attributes().has(PROGUARD_SPECS, BuildType.LABEL_LIST) ? ruleContext.getPrerequisiteArtifacts(PROGUARD_SPECS, Mode.TARGET).list() : ImmutableList.<Artifact>of(); if (optMode == JavaOptimizationMode.LEGACY && proguardSpecs.isEmpty()) { return ImmutableList.of(); } // TODO(bazel-team): In modes except LEGACY verify that proguard specs don't include -dont... // flags since those flags would override the desired optMode ImmutableSortedSet.Builder<Artifact> builder = ImmutableSortedSet.orderedBy(Artifact.EXEC_PATH_COMPARATOR) .addAll(proguardSpecs).addAll(specsToInclude) .addAll(ruleContext.getPrerequisiteArtifacts(":extra_proguard_specs", Mode.TARGET).list()); for (ProguardSpecProvider dep : ruleContext.getPrerequisites("deps", Mode.TARGET, ProguardSpecProvider.class)) { builder.addAll(dep.getTransitiveProguardSpecs()); } // Generate and include implicit Proguard spec for requested mode. if (!optMode.getImplicitProguardDirectives().isEmpty()) { Artifact implicitDirectives = getProguardConfigArtifact(ruleContext, optMode.name().toLowerCase()); ruleContext.registerAction(FileWriteAction.create(ruleContext, implicitDirectives, optMode.getImplicitProguardDirectives(), /*makeExecutable=*/ false)); builder.add(implicitDirectives); } return builder.build().asList(); }