List of usage examples for com.google.common.collect ImmutableSortedSet of
@SuppressWarnings("unchecked") public static <E> ImmutableSortedSet<E> of()
From source file:edu.mit.streamjit.impl.compiler2.Actor.java
/** * Returns the logical indices peeked or popped on the given input during * the given iterations. Note that this method may return a nonempty set * even if peeks(input) returns 0 and isPeeking() returns false. * @param input the input index/* w w w .ja va2s.c o m*/ * @param iterations the iteration numbers * @return the logical indices peeked or popped on the given input during * the given iterations */ public ImmutableSortedSet<Integer> peeks(int input, Set<Integer> iterations) { if (iterations.isEmpty()) return ImmutableSortedSet.of(); if (iterations instanceof ContiguousSet) return peeks(input, (ContiguousSet<Integer>) iterations); ImmutableSortedSet.Builder<Integer> builder = ImmutableSortedSet.naturalOrder(); for (int i : iterations) builder.addAll(peeks(input, i)); return builder.build(); }
From source file:com.facebook.buck.halide.HalideLibraryDescription.java
private CxxBinary createHalideCompiler(BuildRuleParams params, BuildRuleResolver ruleResolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, CxxPlatform cxxPlatform, ImmutableSortedSet<SourceWithFlags> halideSources, ImmutableList<String> compilerFlags, PatternMatchedCollection<ImmutableList<String>> platformCompilerFlags, ImmutableMap<CxxSource.Type, ImmutableList<String>> langCompilerFlags, ImmutableList<String> linkerFlags, PatternMatchedCollection<ImmutableList<String>> platformLinkerFlags, ImmutableList<String> includeDirs) throws NoSuchBuildTargetException { Optional<StripStyle> flavoredStripStyle = StripStyle.FLAVOR_DOMAIN.getValue(params.getBuildTarget()); Optional<LinkerMapMode> flavoredLinkerMapMode = LinkerMapMode.FLAVOR_DOMAIN .getValue(params.getBuildTarget()); params = CxxStrip.removeStripStyleFlavorInParams(params, flavoredStripStyle); params = LinkerMapMode.removeLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode); ImmutableMap<String, CxxSource> srcs = CxxDescriptionEnhancer.parseCxxSources(params.getBuildTarget(), pathResolver, cxxPlatform, halideSources, PatternMatchedCollection.of()); ImmutableList<String> preprocessorFlags = ImmutableList.of(); PatternMatchedCollection<ImmutableList<String>> platformPreprocessorFlags = PatternMatchedCollection.of(); ImmutableMap<CxxSource.Type, ImmutableList<String>> langPreprocessorFlags = ImmutableMap.of(); ImmutableSortedSet<FrameworkPath> frameworks = ImmutableSortedSet.of(); ImmutableSortedSet<FrameworkPath> libraries = ImmutableSortedSet.of(); Optional<SourcePath> prefixHeader = Optional.empty(); Optional<SourcePath> precompiledHeader = Optional.empty(); Optional<Linker.CxxRuntimeType> cxxRuntimeType = Optional.empty(); CxxLinkAndCompileRules cxxLinkAndCompileRules = CxxDescriptionEnhancer.createBuildRulesForCxxBinary(params, ruleResolver, cxxBuckConfig, cxxPlatform, srcs, /* headers */ ImmutableMap.of(), params.getDeps(), flavoredStripStyle, flavoredLinkerMapMode, Linker.LinkableDepType.STATIC, preprocessorFlags, platformPreprocessorFlags, langPreprocessorFlags, frameworks, libraries, compilerFlags, langCompilerFlags, platformCompilerFlags, prefixHeader, precompiledHeader, linkerFlags, platformLinkerFlags, cxxRuntimeType, includeDirs, Optional.empty()); params = CxxStrip.restoreStripStyleFlavorInParams(params, flavoredStripStyle); params = LinkerMapMode.restoreLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode); CxxBinary cxxBinary = new CxxBinary( params.appendExtraDeps(cxxLinkAndCompileRules.executable.getDeps(ruleFinder)), ruleResolver, pathResolver, ruleFinder, cxxLinkAndCompileRules.getBinaryRule(), cxxLinkAndCompileRules.executable, ImmutableSortedSet.of(), ImmutableSortedSet.of(), params.getBuildTarget().withoutFlavors(cxxPlatforms.getFlavors())); ruleResolver.addToIndex(cxxBinary);// www. jav a 2 s. c om return cxxBinary; }
From source file:org.projectbuendia.client.models.LocationTree.java
/** * Returns the sorted descendants of the specified location at the specified depth relative to * that location.//from w w w . j a v a2s. c o m */ public ImmutableSortedSet<Location> getDescendantsAtDepth(Location location, int relativeDepth) { if (location == null) { return ImmutableSortedSet.of(); } if (relativeDepth == 0) { ImmutableSortedSet.Builder<Location> thisLocationSet = ImmutableSortedSet .orderedBy(new LocationComparator(this)); thisLocationSet.add(location); return thisLocationSet.build(); } ImmutableSortedSet.Builder<Location> descendants = ImmutableSortedSet .orderedBy(new LocationComparator(this)); for (Location child : getChildren(location)) { descendants.addAll(getDescendantsAtDepth(child, relativeDepth - 1)); } return descendants.build(); }
From source file:org.apache.james.webadmin.routes.GroupsRoutes.java
@GET @Path(ROOT_PATH)/*from w ww .j ava2 s .c om*/ @ApiOperation(value = "getting groups list") @ApiResponses(value = { @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class), @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.") }) public Set<String> listGroups(Request request, Response response) throws RecipientRewriteTableException { return Optional.ofNullable(recipientRewriteTable.getAllMappings()) .map(mappings -> mappings.entrySet().stream().filter(e -> e.getValue().contains(Mapping.Type.Group)) .map(Map.Entry::getKey).flatMap(source -> OptionalUtils.toStream(source.asMailAddress())) .map(MailAddress::asString).collect(Guavate.toImmutableSortedSet())) .orElse(ImmutableSortedSet.of()); }
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)); }// ww w . j a v a2s . 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.java.PrebuiltJar.java
@Override public ImmutableSortedSet<SourcePath> getJavaSrcs() { return ImmutableSortedSet.of(); }
From source file:org.apache.james.webadmin.routes.ForwardRoutes.java
@GET @Path(ROOT_PATH)/*from w ww . j a va 2 s. c o m*/ @ApiOperation(value = "getting forwards list") @ApiResponses(value = { @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class), @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.") }) public Set<String> listForwards(Request request, Response response) throws RecipientRewriteTableException { return Optional.ofNullable(recipientRewriteTable.getAllMappings()) .map(mappings -> mappings.entrySet().stream() .filter(e -> e.getValue().contains(Mapping.Type.Forward)).map(Map.Entry::getKey) .flatMap(source -> OptionalUtils.toStream(source.asMailAddress())) .map(MailAddress::asString).collect(Guavate.toImmutableSortedSet())) .orElse(ImmutableSortedSet.of()); }
From source file:com.facebook.buck.android.RobolectricTestDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver); JavacOptions javacOptions = JavacOptionsFactory.create(templateOptions, params, resolver, ruleFinder, args); AndroidLibraryGraphEnhancer graphEnhancer = new AndroidLibraryGraphEnhancer(params.getBuildTarget(), params.copyWithExtraDeps(Suppliers.ofInstance(resolver.getAllRules(args.exportedDeps))), javacOptions, DependencyMode.TRANSITIVE, /* forceFinalResourceIds */ true, /* resourceUnionPackage */ Optional.empty(), /* rName */ Optional.empty()); if (params.getBuildTarget().getFlavors().contains(CalculateAbi.FLAVOR)) { if (params.getBuildTarget().getFlavors() .contains(AndroidLibraryGraphEnhancer.DUMMY_R_DOT_JAVA_FLAVOR)) { return graphEnhancer.getBuildableForAndroidResourcesAbi(resolver, ruleFinder); }/*from w w w . j av a2s . c o m*/ BuildTarget testTarget = params.getBuildTarget().withoutFlavors(CalculateAbi.FLAVOR); resolver.requireRule(testTarget); return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params, new BuildTargetSourcePath(testTarget)); } ImmutableList<String> vmArgs = args.vmArgs; Optional<DummyRDotJava> dummyRDotJava = graphEnhancer.getBuildableForAndroidResources(resolver, /* createBuildableIfEmpty */ true); ImmutableSet<Path> additionalClasspathEntries = ImmutableSet.of(); if (dummyRDotJava.isPresent()) { additionalClasspathEntries = ImmutableSet.of(dummyRDotJava.get().getPathToOutput()); ImmutableSortedSet<BuildRule> newExtraDeps = ImmutableSortedSet.<BuildRule>naturalOrder() .addAll(params.getExtraDeps().get()).add(dummyRDotJava.get()).build(); params = params.copyWithExtraDeps(Suppliers.ofInstance(newExtraDeps)); } SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder); JavaTestDescription.CxxLibraryEnhancement cxxLibraryEnhancement = new JavaTestDescription.CxxLibraryEnhancement( params, args.useCxxLibraries, args.cxxLibraryWhitelist, resolver, pathResolver, ruleFinder, cxxPlatform); params = cxxLibraryEnhancement.updatedParams; BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR); // Rewrite dependencies on tests to actually depend on the code which backs the test. BuildRuleParams testsLibraryParams = params.copyWithDeps( Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder() .addAll(params.getDeclaredDeps().get()) .addAll(BuildRules.getExportedRules(Iterables.concat(params.getDeclaredDeps().get(), resolver.getAllRules(args.providedDeps)))) .addAll(ruleFinder.filterBuildRuleInputs(javacOptions.getInputs(ruleFinder))).build()), params.getExtraDeps()).withFlavor(JavaTest.COMPILED_TESTS_LIBRARY_FLAVOR); JavaLibrary testsLibrary = resolver .addToIndex(new DefaultJavaLibrary(testsLibraryParams, pathResolver, ruleFinder, args.srcs, validateResources(pathResolver, params.getProjectFilesystem(), args.resources), javacOptions.getGeneratedSourceFolderName(), args.proguardConfig.map(SourcePaths.toSourcePath(params.getProjectFilesystem())::apply), /* postprocessClassesCommands */ ImmutableList.of(), /* exportDeps */ ImmutableSortedSet.of(), /* providedDeps */ ImmutableSortedSet.of(), abiJarTarget, JavaLibraryRules.getAbiInputs(resolver, testsLibraryParams.getDeps()), javacOptions.trackClassUsage(), additionalClasspathEntries, new JavacToJarStepFactory(javacOptions, new BootClasspathAppender()), args.resourcesRoot, args.manifestFile, args.mavenCoords, /* tests */ ImmutableSortedSet.of(), /* classesToRemoveFromJar */ ImmutableSet.of())); return new RobolectricTest( params.copyWithDeps(Suppliers.ofInstance(ImmutableSortedSet.of(testsLibrary)), Suppliers.ofInstance(ImmutableSortedSet.of())), pathResolver, ruleFinder, testsLibrary, additionalClasspathEntries, args.labels, args.contacts, TestType.JUNIT, javaOptions, vmArgs, cxxLibraryEnhancement.nativeLibsEnvironment, dummyRDotJava, args.testRuleTimeoutMs.map(Optional::of).orElse(defaultTestRuleTimeoutMs), args.testCaseTimeoutMs, args.env, args.getRunTestSeparately(), args.getForkMode(), args.stdOutLogLevel, args.stdErrLogLevel, args.robolectricRuntimeDependency, args.robolectricManifest); }
From source file:org.projectbuendia.client.data.app.AppLocationTree.java
/** * Returns the sorted descendants of the specified location at the specified depth relative to * that location.//w ww .j a va2s . c om */ public ImmutableSortedSet<AppLocation> getDescendantsAtDepth(AppLocation location, int relativeDepth) { if (location == null) { return ImmutableSortedSet.of(); } if (relativeDepth == 0) { ImmutableSortedSet.Builder<AppLocation> thisLocationSet = ImmutableSortedSet .orderedBy(new AppLocationComparator(this)); thisLocationSet.add(location); return thisLocationSet.build(); } ImmutableSortedSet.Builder<AppLocation> descendants = ImmutableSortedSet .orderedBy(new AppLocationComparator(this)); for (AppLocation child : getChildren(location)) { descendants.addAll(getDescendantsAtDepth(child, relativeDepth - 1)); } return descendants.build(); }
From source file:com.spotify.heroic.test.FakeValueProvider.java
private Object lookupParameterized(final ParameterizedType type, final boolean secondary) { if (type.getRawType().equals(Optional.class)) { final Object inner = lookup(type.getActualTypeArguments()[0], secondary); return Optional.of(inner); }/*from w w w . j av a2s . c o m*/ if (type.getRawType().equals(List.class)) { if (secondary) { return ImmutableList.of(); } final Object a = lookup(type.getActualTypeArguments()[0], !secondary); return ImmutableList.of(a); } if (type.getRawType().equals(Set.class)) { if (secondary) { return ImmutableSet.of(); } final Object a = lookup(type.getActualTypeArguments()[0], !secondary); return ImmutableSet.of(a); } if (type.getRawType().equals(SortedSet.class)) { if (secondary) { return ImmutableSortedSet.of(); } final Object a = lookup(type.getActualTypeArguments()[0], !secondary); return ImmutableSortedSet.of((Comparable) a); } if (type.getRawType().equals(Map.class)) { if (secondary) { return ImmutableMap.of(); } final Object keya = lookup(type.getActualTypeArguments()[0], !secondary); final Object a = lookup(type.getActualTypeArguments()[1], !secondary); return ImmutableMap.of(keya, a); } if (type.getRawType().equals(Multimap.class)) { final TreeMultimap<Comparable<?>, Comparable<?>> mm = TreeMultimap.create(); if (secondary) { return mm; } final Object keya = lookup(type.getActualTypeArguments()[0], !secondary); final Object a = lookup(type.getActualTypeArguments()[1], !secondary); mm.put((Comparable<?>) keya, (Comparable<?>) a); return mm; } throw new IllegalArgumentException("Lookup for type (" + type + ") failed"); }