List of usage examples for com.google.common.collect ImmutableSortedSet copyOf
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> copyOf(E[] elements)
From source file:com.facebook.buck.java.DefaultJavaLibrary.java
protected DefaultJavaLibrary(BuildRuleParams buildRuleParams, Set<? extends SourcePath> srcs, Set<? extends SourcePath> resources, Optional<Path> proguardConfig, ImmutableList<String> postprocessClassesCommands, Set<BuildRule> exportedDeps, JavacOptions javacOptions) {//from ww w. ja v a 2s .c o m this.target = buildRuleParams.getBuildTarget(); this.deps = ImmutableSortedSet.<BuildRule>naturalOrder().addAll(buildRuleParams.getDeps()) .addAll(exportedDeps).build(); this.srcs = ImmutableSortedSet.copyOf(srcs); this.resources = ImmutableSortedSet.copyOf(resources); this.proguardConfig = Preconditions.checkNotNull(proguardConfig); this.postprocessClassesCommands = Preconditions.checkNotNull(postprocessClassesCommands); this.exportedDeps = ImmutableSortedSet.copyOf(exportedDeps); this.additionalClasspathEntries = ImmutableSet.of(); this.javacOptions = Preconditions.checkNotNull(javacOptions); if (!srcs.isEmpty() || !resources.isEmpty()) { this.outputJar = Optional.of(getOutputJarPath(getBuildTarget())); } else { this.outputJar = Optional.absent(); } this.outputClasspathEntriesSupplier = Suppliers .memoize(new Supplier<ImmutableSetMultimap<JavaLibrary, Path>>() { @Override public ImmutableSetMultimap<JavaLibrary, Path> get() { return JavaLibraryClasspathProvider.getOutputClasspathEntries(DefaultJavaLibrary.this, outputJar); } }); this.transitiveClasspathEntriesSupplier = Suppliers .memoize(new Supplier<ImmutableSetMultimap<JavaLibrary, Path>>() { @Override public ImmutableSetMultimap<JavaLibrary, Path> get() { return JavaLibraryClasspathProvider.getTransitiveClasspathEntries(DefaultJavaLibrary.this, outputJar); } }); this.declaredClasspathEntriesSupplier = Suppliers .memoize(new Supplier<ImmutableSetMultimap<JavaLibrary, Path>>() { @Override public ImmutableSetMultimap<JavaLibrary, Path> get() { return JavaLibraryClasspathProvider.getDeclaredClasspathEntries(DefaultJavaLibrary.this); } }); this.buildOutputInitializer = new BuildOutputInitializer<>(buildRuleParams.getBuildTarget(), this); }
From source file:dynamicrefactoring.interfaz.editor.classifeditor.ClassifListSection.java
/** * Actualiza la interfaz tras un cambio de clasificacion por parte del * usuario./*ww w. j av a2 s.c o m*/ * * Rellena la tabla con la lista de clasificaciones del catalogo. * * Desactiva ciertos botones si la clasificacion seleccionada no es * editable. * */ private void updateTable() { // borramos los elementos que hay en la tabla tbClassif.remove(0, tbClassif.getItemCount() - 1); // rellenamos con los elementos actuales for (Classification classif : ImmutableSortedSet.copyOf(catalog.getAllClassifications())) { TableItem item = new TableItem(tbClassif, SWT.NONE); if (classif.isEditable()) { item.setImage(RefactoringImages.getClassIcon()); } else { item.setImage(RefactoringImages.getPluginClassificationIcon()); } item.setText(classif.getName()); } }
From source file:de.iteratec.iteraplan.presentation.dialog.GuiController.java
/** * Store all error messages from the complete redirect-chain into the request-scope attribute 'MVC_ERROR_MESSAGES_KEY'. * Must be called at least once, most suitable at the very end of {@link Theme} controller's method(s). * Can be called several times without harm. * // w ww . java 2 s .c om * Use in JSP like this: ${requestScope['iteraplanMvcErrorMessages']} * * Concerning the usage of FlashMap/-Attributes, please refer to comment in * "springmvc-servlet.xml", bean "DefaultAnnotationHandlerMapping". * * @param request The {@link HttpServletRequest} */ @SuppressWarnings("unchecked") protected void storeErrorMessagesInRequestScope(HttpServletRequest request) { List<String> errorMessages = Lists.newArrayList(); // Add error messages from previous requests of the redirect-chain Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request); if (inputFlashMap != null && inputFlashMap.containsKey(SessionConstants.MVC_ERROR_MESSAGES_KEY)) { errorMessages.addAll((List<String>) inputFlashMap.get(SessionConstants.MVC_ERROR_MESSAGES_KEY)); } // Add error messages from the current (and last!) request of the redirect-chain FlashMap outputFlashMap = RequestContextUtils.getOutputFlashMap(request); if (outputFlashMap.containsKey(SessionConstants.MVC_ERROR_MESSAGES_KEY)) { errorMessages.addAll((List<String>) outputFlashMap.get(SessionConstants.MVC_ERROR_MESSAGES_KEY)); } // Use same key for request attribute like for FlashMap key. ImmutableList<String> unqiueErrorMessages = ImmutableSortedSet.copyOf(errorMessages).asList(); request.setAttribute(SessionConstants.MVC_ERROR_MESSAGES_KEY, unqiueErrorMessages); }
From source file:com.facebook.buck.skylark.parser.SkylarkProjectBuildFileParser.java
@Override public BuildFileManifest getBuildFileManifest(Path buildFile) throws BuildFileParseException, InterruptedException, IOException { ParseResult parseResult = parseBuildFile(buildFile); // By contract, BuildFileManifestPojoizer converts any Map to ImmutableMap. // ParseResult.getRawRules() returns ImmutableMap<String, Map<String, Object>>, so it is // a safe downcast here @SuppressWarnings("unchecked") ImmutableMap<String, Map<String, Object>> targets = (ImmutableMap<String, Map<String, Object>>) getBuildFileManifestPojoizer() .convertToPojo(parseResult.getRawRules()); return BuildFileManifest.of(targets, ImmutableSortedSet.copyOf(parseResult.getLoadedPaths()), parseResult.getReadConfigurationOptions(), Optional.empty(), parseResult.getGlobManifestWithResult()); }
From source file:com.google.gerrit.server.StarredChangesUtil.java
public ImmutableSortedSet<String> star(Account.Id accountId, Project.NameKey project, Change.Id changeId, Set<String> labelsToAdd, Set<String> labelsToRemove) throws OrmException { try (Repository repo = repoManager.openRepository(allUsers)) { String refName = RefNames.refsStarredChanges(changeId, accountId); StarRef old = readLabels(repo, refName); Set<String> labels = new HashSet<>(old.labels()); if (labelsToAdd != null) { labels.addAll(labelsToAdd);/*from w ww .j ava2 s . c o m*/ } if (labelsToRemove != null) { labels.removeAll(labelsToRemove); } if (labels.isEmpty()) { deleteRef(repo, refName, old.objectId()); } else { checkMutuallyExclusiveLabels(labels); updateLabels(repo, refName, old.objectId(), labels); } indexer.index(dbProvider.get(), project, changeId); return ImmutableSortedSet.copyOf(labels); } catch (IOException e) { throw new OrmException( String.format("Star change %d for account %d failed", changeId.get(), accountId.get()), e); } }
From source file:es.upm.dit.xsdinferencer.datastructures.Schema.java
/** * This method returns an immutable copy (as an {@link ImmutableMap}) of the map that * maps each namespace URI to its known namespaces. As that map cannot be modified, * it is not necessary to clear the information about * @return an immutable copy of the map that maps each namespace URI to its known namespaces. */// w ww .j a va2 s . c o m public Map<String, SortedSet<String>> getNamespacesToPossiblePrefixMappingUnmodifiable() { Map<String, SortedSet<String>> result = new LinkedHashMap<>(namespaceToKnownPrefixesMapping.size()); for (String uri : namespaceToKnownPrefixesMapping.keySet()) { result.put(uri, ImmutableSortedSet.copyOf(namespaceToKnownPrefixesMapping.get(uri))); } return ImmutableMap.copyOf(result); }
From source file:org.pircbotx.MultiBotManager.java
/** * Get all the bots that this MultiBotManager is managing. * * @return An <i>immutable copy</i> of bots that are being managed *//*from w w w. j av a 2 s . c o m*/ @Synchronized("runningBotsLock") public ImmutableSortedSet<PircBotX> getBots() { return ImmutableSortedSet.copyOf(runningBots.keySet()); }
From source file:uk.ac.ebi.atlas.model.baseline.ExperimentalFactors.java
public SortedSet<Factor> getAllFactors() { return ImmutableSortedSet.copyOf(factorsByType.values()); }
From source file:org.onosproject.onosjar.OnosJarStepFactory.java
private ImmutableSortedSet<Path> findSwaggerModelDefs(SourcePathResolver resolver, ImmutableSortedSet<SourcePath> resourcePaths) { if (resourcePaths == null) { return ImmutableSortedSet.of(); }/* w ww . j a v a2s . c o m*/ return ImmutableSortedSet.copyOf(resourcePaths.stream().filter(sp -> sp.toString().contains(DEFINITIONS)) .map(resolver::getRelativePath).collect(Collectors.toList())); }
From source file:com.facebook.buck.java.DefaultJavaLibraryRule.java
protected DefaultJavaLibraryRule(BuildRuleParams buildRuleParams, Set<String> srcs, Set<? extends SourcePath> resources, Optional<String> proguardConfig, Set<BuildRule> exportedDeps, JavacOptions javacOptions) {/*from w ww .j a v a2 s. c o m*/ super(buildRuleParams); this.srcs = ImmutableSortedSet.copyOf(srcs); this.resources = ImmutableSortedSet.copyOf(resources); this.proguardConfig = Preconditions.checkNotNull(proguardConfig); this.exportedDeps = ImmutableSortedSet.copyOf(exportedDeps); this.javacOptions = Preconditions.checkNotNull(javacOptions); if (!srcs.isEmpty() || !resources.isEmpty()) { this.outputJar = Optional.of(getOutputJarPath(getBuildTarget())); } else { this.outputJar = Optional.absent(); } // Note that both srcs and resources are sorted so that the list order is consistent even if // the iteration order of the sets passed to the constructor changes. See // AbstractBuildRule.getInputsToCompareToOutput() for details. ImmutableList.Builder<String> builder = ImmutableList.<String>builder().addAll(this.srcs); builder.addAll(SourcePaths.filterInputsToCompareToOutput(resources)); inputsToConsiderForCachingPurposes = builder.build(); outputClasspathEntriesSupplier = Suppliers .memoize(new Supplier<ImmutableSetMultimap<JavaLibraryRule, String>>() { @Override public ImmutableSetMultimap<JavaLibraryRule, String> get() { ImmutableSetMultimap.Builder<JavaLibraryRule, String> outputClasspathBuilder = ImmutableSetMultimap .builder(); Iterable<JavaLibraryRule> javaExportedLibraryDeps = Iterables.filter(getExportedDeps(), JavaLibraryRule.class); for (JavaLibraryRule rule : javaExportedLibraryDeps) { outputClasspathBuilder.putAll(rule, rule.getOutputClasspathEntries().values()); // If we have any exported deps, add an entry mapping ourselves to to their, // classpaths so when suggesting libraries to add we know that adding this library // would pull in it's deps. outputClasspathBuilder.putAll(DefaultJavaLibraryRule.this, rule.getOutputClasspathEntries().values()); } if (outputJar.isPresent()) { outputClasspathBuilder.put(DefaultJavaLibraryRule.this, getPathToOutputFile()); } return outputClasspathBuilder.build(); } }); transitiveClasspathEntriesSupplier = Suppliers .memoize(new Supplier<ImmutableSetMultimap<JavaLibraryRule, String>>() { @Override public ImmutableSetMultimap<JavaLibraryRule, String> get() { final ImmutableSetMultimap.Builder<JavaLibraryRule, String> classpathEntries = ImmutableSetMultimap .builder(); ImmutableSetMultimap<JavaLibraryRule, String> classpathEntriesForDeps = Classpaths .getClasspathEntries(getDeps()); ImmutableSetMultimap<JavaLibraryRule, String> classpathEntriesForExportedsDeps = Classpaths .getClasspathEntries(getExportedDeps()); classpathEntries.putAll(classpathEntriesForDeps); // If we have any exported deps, add an entry mapping ourselves to to their classpaths, // so when suggesting libraries to add we know that adding this library would pull in // it's deps. if (!classpathEntriesForExportedsDeps.isEmpty()) { classpathEntries.putAll(DefaultJavaLibraryRule.this, classpathEntriesForExportedsDeps.values()); } // Only add ourselves to the classpath if there's a jar to be built. if (outputJar.isPresent()) { classpathEntries.putAll(DefaultJavaLibraryRule.this, getPathToOutputFile()); } return classpathEntries.build(); } }); declaredClasspathEntriesSupplier = Suppliers .memoize(new Supplier<ImmutableSetMultimap<JavaLibraryRule, String>>() { @Override public ImmutableSetMultimap<JavaLibraryRule, String> get() { final ImmutableSetMultimap.Builder<JavaLibraryRule, String> classpathEntries = ImmutableSetMultimap .builder(); Iterable<JavaLibraryRule> javaLibraryDeps = Iterables.filter(getDeps(), JavaLibraryRule.class); for (JavaLibraryRule rule : javaLibraryDeps) { classpathEntries.putAll(rule, rule.getOutputClasspathEntries().values()); } return classpathEntries.build(); } }); }