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.gradle.language.base.internal.tasks.apigen.abi.MethodSig.java
public MethodSig(int access, String name, String desc, String signature, String[] exceptions) { this.access = access; this.name = name; this.desc = desc; this.signature = signature; this.exceptions = exceptions == null ? Collections.<String>emptySet() : Sets.newTreeSet(ImmutableList.copyOf(exceptions)); }
From source file:com.metamx.druid.indexer.granularity.ArbitraryGranularitySpec.java
@JsonCreator public ArbitraryGranularitySpec(@JsonProperty("intervals") List<Interval> inputIntervals) { intervals = Sets.newTreeSet(Comparators.intervalsByStartThenEnd()); // Insert all intervals for (final Interval inputInterval : inputIntervals) { intervals.add(inputInterval);/* w w w .j a v a 2 s .c o m*/ } // Ensure intervals are non-overlapping (but they may abut each other) final PeekingIterator<Interval> intervalIterator = Iterators.peekingIterator(intervals.iterator()); while (intervalIterator.hasNext()) { final Interval currentInterval = intervalIterator.next(); if (intervalIterator.hasNext()) { final Interval nextInterval = intervalIterator.peek(); if (currentInterval.overlaps(nextInterval)) { throw new IllegalArgumentException( String.format("Overlapping intervals: %s, %s", currentInterval, nextInterval)); } } } }
From source file:org.apache.kylin.common.QueryContextFacade.java
public static TreeSet<QueryContext> getAllRunningQueries() { TreeSet<QueryContext> runningQueries = Sets.newTreeSet(new Comparator<QueryContext>() { @Override/*from w ww. j av a2 s . c o m*/ public int compare(QueryContext o1, QueryContext o2) { if (o2.getAccumulatedMillis() > o1.getAccumulatedMillis()) { return 1; } else if (o2.getAccumulatedMillis() < o1.getAccumulatedMillis()) { return -1; } else { return o1.getQueryId().compareTo(o2.getQueryId()); } } }); runningQueries.addAll(RUNNING_CTX_MAP.values()); return runningQueries; }
From source file:org.apache.aurora.scheduler.base.Numbers.java
/** * Converts a set of integers into a set of contiguous closed ranges that equally represent the * input integers.//from www .j av a 2 s. c om * <p> * The resulting ranges will be in ascending order. * <p> * TODO(wfarner): Change this to return a canonicalized RangeSet. * * @param values Values to transform to ranges. * @return Closed ranges with identical members to the input set. */ public static Set<Range<Integer>> toRanges(Iterable<Integer> values) { ImmutableSet.Builder<Range<Integer>> builder = ImmutableSet.builder(); PeekingIterator<Integer> iterator = Iterators.peekingIterator(Sets.newTreeSet(values).iterator()); // Build ranges until there are no numbers left. while (iterator.hasNext()) { // Start a new range. int start = iterator.next(); int end = start; // Increment the end until the range is non-contiguous. while (iterator.hasNext() && iterator.peek() == end + 1) { end++; iterator.next(); } builder.add(Range.closed(start, end)); } return builder.build(); }
From source file:structures.MedianConstraints.java
public Set[][] copyExclusionSets() { if (this.e != null) { Set[][] copy = new Set[size][size]; for (int i = 0; i < this.size; i++) { for (int j = i; j < this.size; j++) { if (this.e[i][j] != null) { copy[i][j] = Sets.newTreeSet(this.e[i][j]); }//from w ww . j a v a 2 s .c o m } } return copy; } return null; }
From source file:org.incode.eurocommercial.contactapp.dom.role.ContactRoleRepository.java
@Programmatic public SortedSet<String> roleNames() { final ImmutableList<String> roleNames = FluentIterable.from(listAll()).transform(ContactRole::getRoleName) .filter(Predicates.notNull()).toList(); return Sets.newTreeSet(roleNames); }
From source file:org.isisaddons.module.security.shiro.PrincipalForApplicationUser.java
public static PrincipalForApplicationUser from(ApplicationUser applicationUser) { if (applicationUser == null) { return null; }/*from w ww. j ava 2 s. c o m*/ final String username = applicationUser.getName(); final String encryptedPassword = applicationUser.getEncryptedPassword(); final AccountType accountType = applicationUser.getAccountType(); final Set<String> roles = Sets.newTreeSet(Lists .newArrayList(Iterables.transform(applicationUser.getRoles(), ApplicationRole.Functions.GET_NAME))); final ApplicationPermissionValueSet permissionSet = applicationUser.getPermissionSet(); return new PrincipalForApplicationUser(username, encryptedPassword, accountType, applicationUser.getStatus(), roles, permissionSet); }
From source file:example.country.CountryInformation.java
public CountryInformation(Country country, Continent continent, String capital, int population, float areaInSqKm, String currencyCode, Iterable<String> languages) { this.country = checkNotNull(country, "country"); this.continent = checkNotNull(continent, "continent"); this.capital = checkNotNull(capital, "capital"); this.population = checkNotNull(population, "population"); this.areaInSqKm = checkNotNull(areaInSqKm, "area"); this.currencyCode = checkNotNull(currencyCode, "currency code"); this.languages = Sets.newTreeSet(checkNotNull(languages, "languages")); }
From source file:org.estatio.dom.tag.Tags.java
@Programmatic public List<String> choices(final Taggable domainObject, final String tagName) { final List<Tag> tags = doChoices(domainObject, tagName); final Iterable<String> tagNames = Iterables.transform(tags, Tag.GET_VALUE); final TreeSet<String> uniqueSortedTagNames = Sets.newTreeSet(tagNames); return Lists.newArrayList(uniqueSortedTagNames); }
From source file:org.apache.isis.core.metamodel.specloader.validator.ValidationFailures.java
public void assertNone() { if (!occurred()) { return;//from w ww . j a va 2 s .co m } final SortedSet<String> sortedMessages = Sets.newTreeSet(messages); throw new MetaModelInvalidException(sortedMessages); }