List of usage examples for com.google.common.collect Sets newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
From source file:org.jclouds.aws.ec2.predicates.VolumeAttached.java
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables//from w w w . j a va 2s. c o m .getOnlyElement(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())); if (volume.getAttachments().size() == 0) { return false; } Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.ATTACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.ATTACHED; }
From source file:org.gradle.internal.component.AmbiguousConfigurationSelectionException.java
private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, List<ConfigurationMetadata> matches, ComponentResolveMetadata targetComponent) { Set<String> ambiguousConfigurations = Sets.newTreeSet(Lists.transform(matches, CONFIG_NAME)); Set<String> requestedAttributes = Sets .newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME)); StringBuilder sb = new StringBuilder( "Cannot choose between the following configurations on '" + targetComponent + "' : "); JOINER.appendTo(sb, ambiguousConfigurations); sb.append(". All of them match the consumer attributes:"); sb.append("\n"); int maxConfLength = maxLength(ambiguousConfigurations); // We're sorting the names of the configurations and later attributes // to make sure the output is consistently the same between invocations for (final String ambiguousConf : ambiguousConfigurations) { formatConfiguration(sb, fromConfigurationAttributes, consumerSchema, matches, requestedAttributes, maxConfLength, ambiguousConf); }/*from w w w .jav a 2 s. c o m*/ return sb.toString(); }
From source file:com.metamx.druid.SearchBinaryFn.java
@Override public Result<SearchResultValue> apply(Result<SearchResultValue> arg1, Result<SearchResultValue> arg2) { if (arg1 == null) { return arg2; }//ww w. j a va 2 s .co m if (arg2 == null) { return arg1; } SearchResultValue arg1Vals = arg1.getValue(); SearchResultValue arg2Vals = arg2.getValue(); TreeSet<SearchHit> results = Sets.newTreeSet(searchSortSpec.getComparator()); results.addAll(Lists.newArrayList(arg1Vals)); results.addAll(Lists.newArrayList(arg2Vals)); return (gran instanceof AllGranularity) ? new Result<SearchResultValue>(arg1.getTimestamp(), new SearchResultValue(Lists.newArrayList(results))) : new Result<SearchResultValue>(gran.toDateTime(gran.truncate(arg1.getTimestamp().getMillis())), new SearchResultValue(Lists.newArrayList(results))); }
From source file:org.gradle.tooling.internal.consumer.converters.BuildInvocationsConverter.java
private List<ConsumerProvidedTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); collectTasks(project, aggregatedTasks); List<ConsumerProvidedTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new ConsumerProvidedTaskSelector().setName(selectorName).setTaskNames(selectorTasks) .setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)) .setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); }//from w w w . j a v a 2 s . c o m return selectors; }
From source file:com.b2international.snowowl.snomed.reasoner.server.diff.OntologyChangeProcessor.java
public void apply(final long conceptId, final Collection<T> oldCollection, final Collection<T> newCollection, final Ordering<T> ordering, final IProgressMonitor monitor) { final int unitsOfWork = oldCollection.size() + newCollection.size(); final SubMonitor subMonitor = SubMonitor.convert(monitor, "Processing changes...", unitsOfWork); final TreeSet<T> uniqueOlds = Sets.newTreeSet(ordering); final ImmutableList<T> sortedOld = ordering.immutableSortedCopy(oldCollection); final ImmutableList<T> sortedNew = ordering.immutableSortedCopy(newCollection); for (final T oldSubject : sortedOld) { if (subMonitor.isCanceled()) { throw new OperationCanceledException(); }//from ww w.j a v a 2 s .c o m final int idx = ordering.binarySearch(sortedNew, oldSubject); if (idx < 0 || !uniqueOlds.add(oldSubject)) { handleRemovedSubject(String.valueOf(conceptId), oldSubject); } subMonitor.worked(1); } for (final T newSubject : sortedNew) { if (subMonitor.isCanceled()) { throw new OperationCanceledException(); } if (ordering.binarySearch(sortedOld, newSubject) < 0) { handleAddedSubject(String.valueOf(conceptId), newSubject); } subMonitor.worked(1); } }
From source file:com.qcadoo.mes.basic.shift.WorkingHours.java
public WorkingHours(final String hourRanges) { hours = Sets.newTreeSet(Collections.unmodifiableSet(parseIntervals(hourRanges))); }
From source file:edu.harvard.med.screensaver.db.UsersDAOImpl.java
/** * Find all the screening room users that are lab heads. * @return a List of {@link ScreeningRoomUser}s. *//* w w w . j av a 2 s .c om*/ public SortedSet<LabHead> findAllLabHeads() { // note: we perform sorting via a TreeSet, rather than asking persistence // layer to do sorting, as this keeps sorting order policy in // ScreensaverUserComparator, and also keeps our query simpler. Also, the // SortedSet return type makes return value more explicit String hql = "select distinct lh from LabHead " + "lh left outer join lh.labHead " + "left outer join fetch lh.labAffiliation"; SortedSet<LabHead> labHeads = Sets.newTreeSet(ScreensaverUserComparator.getInstance()); ; labHeads.addAll((List<LabHead>) getHibernateSession().createQuery(hql).list()); return labHeads; }
From source file:com.gwtplatform.dispatch.rest.rebind.resource.MethodDefinition.java
public Set<String> getImports() { return Sets.newTreeSet(imports); }
From source file:com.android.tools.idea.welcome.wizard.InstallSummaryStep.java
@Nullable private static String getPackagesTable(@NotNull Collection<RemotePackage> remotePackages) { if (remotePackages.isEmpty()) { return null; }/*from ww w . j a va2 s . c o m*/ TreeSet<RemotePackage> sortedPackagesList = Sets.newTreeSet(new PackageInfoComparator()); sortedPackagesList.addAll(remotePackages); StringBuilder table = new StringBuilder("<table>"); for (RemotePackage remotePkgInfo : sortedPackagesList) { Archive archive = remotePkgInfo.getArchive(); assert archive != null; // Adds some whitespace between name and size columns table.append("<tr><td>").append(remotePkgInfo.getDisplayName()).append("</td><td> </td><td>") .append(WelcomeUIUtils.getSizeLabel(archive.getComplete().getSize())).append("</td></tr>"); } table.append("</table>"); return table.toString(); }
From source file:org.opentestsystem.shared.progman.domain.TenantChain.java
public void addTenantToChain(final Tenant inTenant) { if (this.tenants == null) { this.tenants = Sets.newTreeSet(new ReverseTenantComparator()); }//from ww w .j av a2 s. c om this.tenants.add(inTenant); }