List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:com.google.template.soy.jssrc.internal.FindCalleesNotInFileVisitor.java
@Override protected void visitSoyFileNode(SoyFileNode node) { templatesInFile = Sets.newHashSet(); for (TemplateNode template : node.getChildren()) { templatesInFile.add(template.getTemplateName()); }//from w w w .j a v a2 s . co m calleesNotInFile = Sets.newTreeSet(); visitChildren(node); }
From source file:blockplus.model.polyomino.Polyominos.java
private Polyominos() { final Builder<String, Polyomino> typesBuilder = new ImmutableSortedMap.Builder<String, Polyomino>( Ordering.natural());/*w w w .ja v a2 s.com*/ final Builder<String, PolyominoInstance> instancesBuilder = new ImmutableSortedMap.Builder<String, PolyominoInstance>( Ordering.natural()); final Set<Integer> radius = Sets.newTreeSet(); for (final Polyomino polyomino : Polyomino.set()) { for (final PolyominoInstance instance : polyomino.get()) { final String representation = instance.toString(); typesBuilder.put(representation, polyomino); instancesBuilder.put(representation, instance); radius.add(polyomino.radius()); } } this.typeIndexes = typesBuilder.build(); this.instanceIndexes = instancesBuilder.build(); this.radiusIndexes = computeRadiusIndexes(radius); }
From source file:org.incode.module.document.dom.impl.docs.Document_supports.java
private Set<Document> supportedDocumentsNoCache(final Document supportingDocumentCandidate) { Set<Document> documents = Sets.newTreeSet(); for (SupportingDocumentsEvaluator supportingDocumentsEvaluator : supportingDocumentsEvaluators) { List<Document> supportedDocuments = supportingDocumentsEvaluator .supportedBy(supportingDocumentCandidate); if (supportedDocuments != null) { documents.addAll(supportedDocuments); }// w w w.j av a 2 s .co m } return documents; }
From source file:org.incode.eurocommercial.contactapp.dom.contacts.ContactRepository.java
@Programmatic public java.util.List<Contact> findByContactGroup(ContactGroup contactGroup) { java.util.SortedSet<Contact> contacts = Sets.newTreeSet(); for (ContactRole contactRole : contactRoleRepository.findByGroup(contactGroup)) { contacts.add(contactRole.getContact()); }// w w w . j ava 2s. c o m return asSortedList(contacts); }
From source file:org.apache.helix.task.FixedTargetTaskRebalancer.java
/** * Returns the set of all partition ids for a job. * <p/>// w ww. j a v a2s . co m * If a set of partition ids was explicitly specified in the config, that is used. Otherwise, we * use the list of all partition ids from the target resource. */ private static Set<Integer> getAllTaskPartitions(IdealState tgtResourceIs, JobConfig jobCfg, JobContext taskCtx) { if (tgtResourceIs == null) { return null; } Map<String, List<Integer>> currentTargets = taskCtx.getPartitionsByTarget(); SortedSet<String> targetPartitions = Sets.newTreeSet(); if (jobCfg.getTargetPartitions() != null) { targetPartitions.addAll(jobCfg.getTargetPartitions()); } else { targetPartitions.addAll(tgtResourceIs.getPartitionSet()); } Set<Integer> taskPartitions = Sets.newTreeSet(); for (String pName : targetPartitions) { taskPartitions.addAll(getPartitionsForTargetPartition(pName, currentTargets, taskCtx)); } return taskPartitions; }
From source file:com.github.nethad.clustermeister.provisioning.ec2.CredentialsManager.java
/** * Returns a sorted set with all configured, persisted and runtime credentials. * //ww w . j a va 2s . c o m * Note: When calling this method for the first time there may be a slight delay. * * @return a newly created sorted set containing all currently known keypairs. */ public SortedSet<Credentials> getAllCredentials() { SortedSet<Credentials> sortedSet = Sets.newTreeSet(); sortedSet.addAll(ImmutableSet.copyOf(configuredCredentials)); sortedSet.addAll(ImmutableSet.copyOf(getNodeKeyPairs())); return sortedSet; }
From source file:com.google.idea.blaze.android.resources.actions.BlazeCreateResourceUtils.java
static void setupResDirectoryChoices(Project project, @Nullable VirtualFile contextFile, JBLabel resDirLabel, ComboboxWithBrowseButton resDirComboAndBrowser) { // Reset the item list before filling it back up. resDirComboAndBrowser.getComboBox().removeAllItems(); BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (blazeProjectData != null) { BlazeAndroidSyncData syncData = blazeProjectData.syncState.get(BlazeAndroidSyncData.class); if (syncData != null) { ImmutableCollection<TargetKey> rulesRelatedToContext = null; File fileFromContext = null; if (contextFile != null) { fileFromContext = VfsUtilCore.virtualToIoFile(contextFile); rulesRelatedToContext = SourceToTargetMap.getInstance(project) .getRulesForSourceFile(fileFromContext); if (rulesRelatedToContext.isEmpty()) { rulesRelatedToContext = null; }//w w w. j a v a 2s .co m } ArtifactLocationDecoder artifactLocationDecoder = blazeProjectData.artifactLocationDecoder; // Sort: // - contextFile/res if contextFile is a directory, // to optimize the right click on directory case, or the "closest" string // match to the contextFile from the res directories known to blaze // - the rest of the direct dirs, then transitive dirs of the context rules, // then any known res dir in the project // as a backup, in alphabetical order. Set<File> resourceDirs = Sets.newTreeSet(); Set<File> transitiveDirs = Sets.newTreeSet(); Set<File> allResDirs = Sets.newTreeSet(); for (AndroidResourceModule androidResourceModule : syncData.importResult.androidResourceModules) { Collection<File> resources = artifactLocationDecoder.decodeAll(androidResourceModule.resources); Collection<File> transitiveResources = artifactLocationDecoder .decodeAll(androidResourceModule.transitiveResources); // labelsRelatedToContext should include deps, // but as a first pass we only check the rules themselves // for resources. If we come up empty, then have anyResDir as a backup. allResDirs.addAll(transitiveResources); if (rulesRelatedToContext != null && !rulesRelatedToContext.contains(androidResourceModule.targetKey)) { continue; } resourceDirs.addAll(resources); transitiveDirs.addAll(transitiveResources); } // No need to show some directories twice. transitiveDirs.removeAll(resourceDirs); JComboBox resDirCombo = resDirComboAndBrowser.getComboBox(); // Allow the user to browse and overwrite some of the entries, // in case our inference is wrong. resDirCombo.setEditable(true); // Optimize the right-click on a non-res directory (consider res directory right under that) // After the use confirms the choice, a directory will be created if it is missing. if (fileFromContext != null && fileFromContext.isDirectory()) { File closestDirToContext = new File(fileFromContext.getPath(), "res"); resDirCombo.setSelectedItem(closestDirToContext); } else { // If we're not completely sure, let people know there are options // via the placeholder text, and put the most likely on top. String placeHolder = PLACEHOLDER_TEXT; resDirCombo.addItem(placeHolder); resDirCombo.setSelectedItem(placeHolder); if (fileFromContext != null) { File closestDirToContext = findClosestDirToContext(fileFromContext.getPath(), resourceDirs); closestDirToContext = closestDirToContext != null ? closestDirToContext : findClosestDirToContext(fileFromContext.getPath(), transitiveDirs); if (closestDirToContext != null) { resDirCombo.addItem(closestDirToContext); resourceDirs.remove(closestDirToContext); transitiveDirs.remove(closestDirToContext); } } } if (!resourceDirs.isEmpty() || !transitiveDirs.isEmpty()) { for (File resourceDir : resourceDirs) { resDirCombo.addItem(resourceDir); } for (File resourceDir : transitiveDirs) { resDirCombo.addItem(resourceDir); } } else { for (File resourceDir : allResDirs) { resDirCombo.addItem(resourceDir); } } resDirComboAndBrowser.setVisible(true); resDirLabel.setVisible(true); } } }
From source file:org.locationtech.geogig.api.plumbing.merge.CheckMergeScenarioOp.java
@Override protected Boolean _call() { if (commits.size() < 2) { return Boolean.FALSE; }/*from www .j a v a 2 s .c o m*/ Optional<ObjectId> ancestor = command(FindCommonAncestor.class).setLeft(commits.get(0)) .setRight(commits.get(1)).call(); Preconditions.checkState(ancestor.isPresent(), "No ancestor commit could be found."); for (int i = 2; i < commits.size(); i++) { ancestor = command(FindCommonAncestor.class).setLeft(commits.get(i)).setRightId(ancestor.get()).call(); Preconditions.checkState(ancestor.isPresent(), "No ancestor commit could be found."); } Map<String, List<DiffEntry>> diffs = Maps.newHashMap(); Set<String> removedPaths = Sets.newTreeSet(); // we organize the changes made for each path for (RevCommit commit : commits) { Iterator<DiffEntry> toMergeDiffs = command(DiffTree.class).setReportTrees(true) .setOldTree(ancestor.get()).setNewTree(commit.getId()).call(); while (toMergeDiffs.hasNext()) { DiffEntry diff = toMergeDiffs.next(); String path = diff.oldPath() == null ? diff.newPath() : diff.oldPath(); if (diffs.containsKey(path)) { diffs.get(path).add(diff); } else { diffs.put(path, Lists.newArrayList(diff)); } if (ChangeType.REMOVED.equals(diff.changeType())) { removedPaths.add(path); } } } // now we check that, for any path, changes are compatible Collection<List<DiffEntry>> values = diffs.values(); for (List<DiffEntry> list : values) { for (int i = 0; i < list.size(); i++) { for (int j = i + 1; j < list.size(); j++) { if (hasConflicts(list.get(i), list.get(j))) { return true; } } if (!ChangeType.REMOVED.equals(list.get(i).changeType())) { if (removedPaths.contains(list.get(i).getNewObject().getParentPath())) { return true; } } } } return false; }
From source file:org.apache.helix.task.FixedTargetTaskAssignmentCalculator.java
/** * Returns the set of all partition ids for a job. * If a set of partition ids was explicitly specified in the config, that is used. Otherwise, we * use the list of all partition ids from the target resource. * return empty set if target resource does not exist. *///w w w . ja v a2 s .c o m private static Set<Integer> getAllTaskPartitions(IdealState tgtResourceIs, JobConfig jobCfg, JobContext taskCtx) { Map<String, List<Integer>> currentTargets = taskCtx.getPartitionsByTarget(); SortedSet<String> targetPartitions = Sets.newTreeSet(); if (jobCfg.getTargetPartitions() != null) { targetPartitions.addAll(jobCfg.getTargetPartitions()); } else { if (tgtResourceIs != null) { targetPartitions.addAll(tgtResourceIs.getPartitionSet()); } else { LOG.warn("Missing target resource for the scheduled job!"); } } Set<Integer> taskPartitions = Sets.newTreeSet(); for (String pName : targetPartitions) { taskPartitions.addAll(getPartitionsForTargetPartition(pName, currentTargets, taskCtx)); } return taskPartitions; }
From source file:org.apache.drill.exec.server.rest.LogsResources.java
@GET @Path("/logs.json") @Produces(MediaType.APPLICATION_JSON)//from w w w. java2 s .co m public Set<Log> getLogsJSON() { Set<Log> logs = Sets.newTreeSet(); File[] files = getLogFolder().listFiles(file_filter); for (File file : files) { logs.add(new Log(file.getName(), file.length(), file.lastModified())); } return logs; }