List of usage examples for com.google.common.collect ImmutableSortedSet.Builder add
boolean add(E e);
From source file:com.facebook.buck.apple.AppleDescriptions.java
public static void populateCxxConstructorArg(SourcePathResolver resolver, CxxConstructorArg output, AppleNativeTargetDescriptionArg arg, BuildTarget buildTarget) { Path headerPathPrefix = AppleDescriptions.getHeaderPathPrefix(arg, buildTarget); // The resulting cxx constructor arg will have no exported headers and both headers and exported // headers specified in the apple arg will be available with both public and private include // styles./*from w ww . ja va 2 s .co m*/ ImmutableSortedMap<String, SourcePath> headerMap = ImmutableSortedMap.<String, SourcePath>naturalOrder() .putAll(convertAppleHeadersToPublicCxxHeaders(resolver::getRelativePath, headerPathPrefix, arg)) .putAll(convertAppleHeadersToPrivateCxxHeaders(resolver::getRelativePath, headerPathPrefix, arg)) .build(); ImmutableSortedSet.Builder<SourceWithFlags> nonSwiftSrcs = ImmutableSortedSet.naturalOrder(); for (SourceWithFlags src : arg.srcs) { if (!MorePaths.getFileExtension(resolver.getAbsolutePath(src.getSourcePath())) .equalsIgnoreCase(SWIFT_EXTENSION)) { nonSwiftSrcs.add(src); } } output.srcs = nonSwiftSrcs.build(); output.platformSrcs = arg.platformSrcs; output.headers = SourceList.ofNamedSources(headerMap); output.platformHeaders = arg.platformHeaders; output.prefixHeader = arg.prefixHeader; output.compilerFlags = arg.compilerFlags; output.platformCompilerFlags = arg.platformCompilerFlags; output.langCompilerFlags = arg.langCompilerFlags; output.preprocessorFlags = arg.preprocessorFlags; output.platformPreprocessorFlags = arg.platformPreprocessorFlags; output.langPreprocessorFlags = arg.langPreprocessorFlags; output.linkerFlags = arg.linkerFlags; output.platformLinkerFlags = arg.platformLinkerFlags; output.frameworks = arg.frameworks; output.libraries = arg.libraries; output.deps = arg.deps; // This is intentionally an empty string; we put all prefixes into // the header map itself. output.headerNamespace = Optional.of(""); output.cxxRuntimeType = arg.cxxRuntimeType; output.tests = arg.tests; output.precompiledHeader = arg.precompiledHeader; }
From source file:com.google.devtools.build.lib.rules.android.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 2s .com * * <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 AndroidBinary#createAndroidBinary} relies on that behavior. */ public static ImmutableList<Artifact> collectTransitiveProguardSpecs(RuleContext ruleContext, 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).add(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(new FileWriteAction(ruleContext.getActionOwner(), implicitDirectives, optMode.getImplicitProguardDirectives(), /*executable*/ false)); builder.add(implicitDirectives); } return builder.build().asList(); }
From source file:com.facebook.buck.jvm.java.JarBackedJavacProvider.java
@Override public Javac resolve(SourcePathRuleFinder ruleFinder) { if (javac == null) { ImmutableSortedSet.Builder<SourcePath> builder = ImmutableSortedSet.naturalOrder(); builder.add(javacJarPath); // Add transitive deps if any exist so that everything needed is available Optional<BuildRule> possibleRule = ruleFinder.getRule(javacJarPath); if (possibleRule.isPresent() && possibleRule.get() instanceof JavaLibrary) { JavaLibrary compilerLibrary = (JavaLibrary) possibleRule.get(); builder.addAll(compilerLibrary.getTransitiveClasspaths()); }/*www .ja v a 2s . com*/ ImmutableSortedSet<SourcePath> fullJavacClasspath = builder.build(); javac = new JarBackedJavac(compilerClassName, fullJavacClasspath); } return javac; }
From source file:com.palantir.atlasdb.table.description.render.ImportRenderer.java
private SortedSet<String> importsSortedByFullName() { ImmutableSortedSet.Builder<String> sortedImports = ImmutableSortedSet.naturalOrder(); for (Class<?> clazz : imports) { sortedImports.add(clazz.getCanonicalName()); }//from w w w . ja v a2 s . c o m return sortedImports.build(); }
From source file:com.palantir.atlasdb.table.description.render.ImportRenderer.java
private SortedSet<String> importsSortedBySimpleName() { ImmutableSortedSet.Builder<String> sortedImports = ImmutableSortedSet.naturalOrder(); for (Class<?> clazz : imports) { sortedImports.add(clazz.getSimpleName()); }/*from www . j a v a 2s. c o m*/ return sortedImports.build(); }
From source file:com.isotrol.impe3.web20.impl.TimeMap.java
private TimeMap(TimeMapConfig config, SchedulerComponent scheduler, WithTimeMapManager<M> manager) { this.maps = new MapMaker().makeMap(); this.manager = checkNotNull(manager); ImmutableSortedSet.Builder<Long> ib = ImmutableSortedSet.naturalOrder(); if (config.isGlobal()) { ib.add(Long.MAX_VALUE); this.maps.put(Long.MAX_VALUE, manager.createEmptyTimeMap()); scheduler.scheduleWithFixedDelay(new Task(null), 0L, config.getDelay(), TimeUnit.SECONDS); }/*from w w w .ja v a2 s . c o m*/ for (Long seconds : config.getIntervals()) { ib.add(seconds); this.maps.put(seconds, manager.createEmptyTimeMap()); scheduler.scheduleWithFixedDelay(new Task(seconds), 0L, config.getDelay(), TimeUnit.SECONDS); } this.intervals = ib.build(); }
From source file:com.facebook.buck.versions.VersionRootBuilder.java
public VersionRootBuilder setDeps(String... deps) { ImmutableSortedSet.Builder<BuildTarget> builder = ImmutableSortedSet.naturalOrder(); for (String dep : deps) { builder.add(BuildTargetFactory.newInstance(dep)); }//from w w w . ja va 2 s.c om return setDeps(builder.build()); }
From source file:com.facebook.buck.versions.VersionPropagatorBuilder.java
public VersionPropagatorBuilder setDeps(String... deps) { ImmutableSortedSet.Builder<BuildTarget> builder = ImmutableSortedSet.naturalOrder(); for (String dep : deps) { builder.add(BuildTargetFactory.newInstance(dep)); }// w ww . j a v a2 s .c o m return setDeps(builder.build()); }
From source file:com.google.devtools.build.lib.skyframe.serialization.ImmutableSortedSetCodec.java
@Override public ImmutableSortedSet<E> deserialize(DeserializationContext context, CodedInputStream codedIn) throws SerializationException, IOException { ImmutableSortedSet.Builder<E> builder = ImmutableSortedSet.orderedBy(context.deserialize(codedIn)); int size = codedIn.readInt32(); for (int i = 0; i < size; i++) { builder.add(context.<E>deserialize(codedIn)); }//from w ww .java 2 s . c om return builder.build(); }
From source file:se.sics.caracaldb.utils.TimestampIdFactory.java
@Override public synchronized ImmutableSortedSet<UUID> newIds(int n) { checkUpdateTs();/*w w w . j a va2 s . c om*/ ImmutableSortedSet.Builder<UUID> idBuilder = ImmutableSortedSet.naturalOrder(); for (int i = 0; i < n; i++) { idBuilder.add(nextId()); } return idBuilder.build(); }