List of usage examples for com.google.common.collect ImmutableSortedSet contains
@Override public boolean contains(@Nullable Object object)
From source file:com.facebook.buck.cxx.toolchain.HeaderSymlinkTreeWithModuleMap.java
private static boolean containsSwiftHeader(ImmutableSortedSet<Path> paths, String moduleName) { return paths.contains(Paths.get(moduleName, moduleName + "-Swift.h")); }
From source file:com.facebook.buck.features.js.HasBundleName.java
/** Computes the bundle name as configured, or falls back to a default name. */ default String computeBundleName(ImmutableSortedSet<Flavor> flavors, Supplier<String> defaultName) { for (Pair<Flavor, String> nameForFlavor : getBundleNameForFlavor()) { if (flavors.contains(nameForFlavor.getFirst())) { return nameForFlavor.getSecond(); }/*from ww w . j ava 2s.c om*/ } return getBundleName().orElseGet(defaultName); }
From source file:org.voltcore.utils.COWNavigableSet.java
@Override public boolean add(E e) { while (true) { ImmutableSortedSet<E> snapshot = m_set.get(); if (snapshot.contains(e)) return false; ImmutableSortedSet.Builder<E> builder = ImmutableSortedSet.naturalOrder(); builder.addAll(snapshot);/*from ww w.ja v a2 s .c o m*/ builder.add(e); if (m_set.compareAndSet(snapshot, builder.build())) { return true; } } }
From source file:org.voltcore.utils.COWNavigableSet.java
@Override public boolean remove(Object o) { while (true) { ImmutableSortedSet<E> snapshot = m_set.get(); if (!snapshot.contains(o)) return false; ImmutableSortedSet.Builder<E> builder = ImmutableSortedSet.naturalOrder(); for (E e : snapshot) { if (e.equals(o)) continue; builder.add(e);//from w w w . ja va 2 s . c om } if (m_set.compareAndSet(snapshot, builder.build())) { return true; } } }
From source file:com.facebook.buck.jvm.kotlin.KotlinLibraryDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver); BuildTarget target = params.getBuildTarget(); // We know that the flavour we're being asked to create is valid, since the check is done when // creating the action graph from the target graph. ImmutableSortedSet<Flavor> flavors = target.getFlavors(); if (flavors.contains(CalculateAbi.FLAVOR)) { BuildTarget libraryTarget = params.getBuildTarget().withoutFlavors(CalculateAbi.FLAVOR); resolver.requireRule(libraryTarget); return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params, new BuildTargetSourcePath(libraryTarget)); }/*w ww. j a v a 2 s.c o m*/ SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder); BuildRuleParams paramsWithMavenFlavor = null; if (flavors.contains(JavaLibrary.MAVEN_JAR)) { paramsWithMavenFlavor = params; // Maven rules will depend upon their vanilla versions, so the latter have to be constructed // without the maven flavor to prevent output-path conflict params = params.copyWithBuildTarget( params.getBuildTarget().withoutFlavors(ImmutableSet.of(JavaLibrary.MAVEN_JAR))); } if (flavors.contains(JavaLibrary.SRC_JAR)) { args.mavenCoords = args.mavenCoords .map(input -> AetherUtil.addClassifier(input, AetherUtil.CLASSIFIER_SOURCES)); if (!flavors.contains(JavaLibrary.MAVEN_JAR)) { return new JavaSourceJar(params, pathResolver, args.srcs, args.mavenCoords); } else { return MavenUberJar.SourceJar.create(Preconditions.checkNotNull(paramsWithMavenFlavor), pathResolver, args.srcs, args.mavenCoords, args.mavenPomTemplate); } } JavacOptions javacOptions = JavacOptionsFactory.create(defaultOptions, params, resolver, ruleFinder, args); BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR); ImmutableSortedSet<BuildRule> exportedDeps = resolver.getAllRules(args.exportedDeps); BuildRuleParams javaLibraryParams = params.appendExtraDeps(Iterables.concat( BuildRules.getExportedRules(Iterables.concat(params.getDeclaredDeps().get(), exportedDeps, resolver.getAllRules(args.providedDeps))), ruleFinder.filterBuildRuleInputs(javacOptions.getInputs(ruleFinder)))); DefaultKotlinLibrary defaultKotlinLibrary = new DefaultKotlinLibrary(javaLibraryParams, pathResolver, ruleFinder, args.srcs, validateResources(pathResolver, params.getProjectFilesystem(), args.resources), Optional.empty(), Optional.empty(), ImmutableList.of(), exportedDeps, resolver.getAllRules(args.providedDeps), abiJarTarget, JavaLibraryRules.getAbiInputs(resolver, javaLibraryParams.getDeps()), false, ImmutableSet.of(), new KotlincToJarStepFactory(kotlinBuckConfig.getKotlinCompiler().get(), args.extraKotlincArguments), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableSortedSet.of(), ImmutableSet.of()); if (!flavors.contains(JavaLibrary.MAVEN_JAR)) { return defaultKotlinLibrary; } else { return MavenUberJar.create(defaultKotlinLibrary, Preconditions.checkNotNull(paramsWithMavenFlavor), pathResolver, args.mavenCoords, args.mavenPomTemplate); } }
From source file:com.facebook.buck.simulate.SimulateTimes.java
private SimulateTimes(ImmutableMap<String, ImmutableMap<String, Long>> buildTargetTimes, ImmutableSortedSet<String> timeAggregates, String file, long defaultMillis) { this.buildTargetTimes = buildTargetTimes; this.file = file; Preconditions.checkState(!timeAggregates.contains(DEFAULT_TIME_AGGREGATE_KEY), "Time aggregate key '%s' is reserved and should not be used.", DEFAULT_TIME_AGGREGATE_KEY); this.timeAggregates = ImmutableSortedSet.<String>naturalOrder().addAll(timeAggregates) .add(DEFAULT_TIME_AGGREGATE_KEY).build(); this.ruleFallbackTimeMillis = defaultMillis; }
From source file:com.facebook.buck.jvm.java.JavaLibraryDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver); SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder); BuildTarget target = params.getBuildTarget(); // We know that the flavour we're being asked to create is valid, since the check is done when // creating the action graph from the target graph. ImmutableSortedSet<Flavor> flavors = target.getFlavors(); if (flavors.contains(Javadoc.DOC_JAR)) { BuildTarget unflavored = BuildTarget.of(target.getUnflavoredBuildTarget()); BuildRule baseLibrary = resolver.requireRule(unflavored); JarShape shape = params.getBuildTarget().getFlavors().contains(JavaLibrary.MAVEN_JAR) ? JarShape.MAVEN : JarShape.SINGLE;//from www . j a v a 2 s.c o m JarShape.Summary summary = shape.gatherDeps(baseLibrary); ImmutableSet<SourcePath> sources = summary.getPackagedRules().stream() .filter(HasSources.class::isInstance).map(rule -> ((HasSources) rule).getSources()) .flatMap(Collection::stream).collect(MoreCollectors.toImmutableSet()); // In theory, the only deps we need are the ones that contribute to the sourcepaths. However, // javadoc wants to have classes being documented have all their deps be available somewhere. // Ideally, we'd not build everything, but then we're not able to document any classes that // rely on auto-generated classes, such as those created by the Immutables library. Oh well. // Might as well add them as deps. *sigh* ImmutableSortedSet.Builder<BuildRule> deps = ImmutableSortedSet.naturalOrder(); // Sourcepath deps deps.addAll(ruleFinder.filterBuildRuleInputs(sources)); // Classpath deps deps.add(baseLibrary); deps.addAll(summary.getClasspath().stream() .filter(rule -> HasClasspathEntries.class.isAssignableFrom(rule.getClass())) .flatMap(rule -> rule.getTransitiveClasspathDeps().stream()).iterator()); BuildRuleParams emptyParams = params.copyWithDeps(Suppliers.ofInstance(deps.build()), Suppliers.ofInstance(ImmutableSortedSet.of())); return new Javadoc(emptyParams, pathResolver, args.mavenCoords, args.mavenPomTemplate, summary.getMavenDeps(), sources); } if (flavors.contains(CalculateAbi.FLAVOR)) { BuildTarget libraryTarget = target.withoutFlavors(CalculateAbi.FLAVOR); resolver.requireRule(libraryTarget); return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params, new BuildTargetSourcePath(libraryTarget)); } BuildRuleParams paramsWithMavenFlavor = null; if (flavors.contains(JavaLibrary.MAVEN_JAR)) { paramsWithMavenFlavor = params; // Maven rules will depend upon their vanilla versions, so the latter have to be constructed // without the maven flavor to prevent output-path conflict params = params.copyWithBuildTarget( params.getBuildTarget().withoutFlavors(ImmutableSet.of(JavaLibrary.MAVEN_JAR))); } if (flavors.contains(JavaLibrary.SRC_JAR)) { args.mavenCoords = args.mavenCoords .map(input -> AetherUtil.addClassifier(input, AetherUtil.CLASSIFIER_SOURCES)); if (!flavors.contains(JavaLibrary.MAVEN_JAR)) { return new JavaSourceJar(params, pathResolver, args.srcs, args.mavenCoords); } else { return MavenUberJar.SourceJar.create(Preconditions.checkNotNull(paramsWithMavenFlavor), pathResolver, args.srcs, args.mavenCoords, args.mavenPomTemplate); } } JavacOptions javacOptions = JavacOptionsFactory.create(defaultOptions, params, resolver, ruleFinder, args); BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR); ImmutableSortedSet<BuildRule> exportedDeps = resolver.getAllRules(args.exportedDeps); BuildRuleParams javaLibraryParams = params.appendExtraDeps(Iterables.concat( BuildRules.getExportedRules(Iterables.concat(params.getDeclaredDeps().get(), exportedDeps, resolver.getAllRules(args.providedDeps))), ruleFinder.filterBuildRuleInputs(javacOptions.getInputs(ruleFinder)))); DefaultJavaLibrary defaultJavaLibrary = new DefaultJavaLibrary(javaLibraryParams, pathResolver, ruleFinder, args.srcs, validateResources(pathResolver, params.getProjectFilesystem(), args.resources), javacOptions.getGeneratedSourceFolderName(), args.proguardConfig.map(SourcePaths.toSourcePath(params.getProjectFilesystem())::apply), args.postprocessClassesCommands, exportedDeps, resolver.getAllRules(args.providedDeps), abiJarTarget, JavaLibraryRules.getAbiInputs(resolver, javaLibraryParams.getDeps()), javacOptions.trackClassUsage(), /* additionalClasspathEntries */ ImmutableSet.of(), new JavacToJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY), args.resourcesRoot, args.manifestFile, args.mavenCoords, args.tests, javacOptions.getClassesToRemoveFromJar()); if (!flavors.contains(JavaLibrary.MAVEN_JAR)) { return defaultJavaLibrary; } else { return MavenUberJar.create(defaultJavaLibrary, Preconditions.checkNotNull(paramsWithMavenFlavor), pathResolver, args.mavenCoords, args.mavenPomTemplate); } }
From source file:com.facebook.buck.features.js.JsLibrary.java
private ObjectBuilder getJobArgs(SourcePathResolver resolver, Path outputPath) { ImmutableSortedSet<Flavor> flavors = getBuildTarget().getFlavors(); return JsonBuilder.object().addString("command", "library-dependencies") .addBoolean("release", flavors.contains(JsFlavors.RELEASE)) .addString("rootPath", getProjectFilesystem().getRootPath().toString()) .addString("platform", JsUtil.getPlatformString(flavors)) .addString("outputPath", outputPath.toString()) .addArray("dependencyLibraryFilePaths", libraryDependencies.stream().map(resolver::getAbsolutePath).map(Path::toString) .collect(JsonBuilder.toArrayOfStrings())) .addString("aggregatedSourceFilesFilePath", resolver.getAbsolutePath(filesDependency).toString()); }
From source file:eu.eidas.auth.commons.attribute.AttributeRegistry.java
/** * Returns {@code true} when this instance contains the given attribute definition, {@code false} otherwise. * * @param attributeDefinition the attribute definition to look up * @return {@code true} when this instance contains the given attribute definition, {@code false} otherwise. *///from w w w . j a v a 2 s . c o m public boolean contains(@Nonnull AttributeDefinition<?> attributeDefinition) { Preconditions.checkNotNull(attributeDefinition, "attributeDefinition"); try { for (final SingletonAccessor<ImmutableSortedSet<AttributeDefinition<?>>> accessor : getAccessors()) { ImmutableSortedSet<AttributeDefinition<?>> attributeDefinitions = accessor.get(); if (null != attributeDefinitions && attributeDefinitions.contains(attributeDefinition)) { return true; } } } catch (IOException ioe) { throw new InternalErrorEIDASException(EidasErrorKey.INTERNAL_ERROR.errorCode(), ioe.getMessage(), ioe); } return false; }
From source file:org.voltcore.utils.COWNavigableSet.java
@Override public boolean addAll(Collection<? extends E> c) { while (true) { ImmutableSortedSet<E> snapshot = m_set.get(); ImmutableSortedSet.Builder<E> builder = ImmutableSortedSet.naturalOrder(); boolean hadValues = false; for (E e : c) { if (!snapshot.contains(e)) { builder.add(e);/*from w ww. j a v a2s . c o m*/ hadValues = true; } } if (hadValues) { builder.addAll(snapshot); if (m_set.compareAndSet(snapshot, builder.build())) { return true; } } else { return false; } } }