List of usage examples for com.google.common.collect Ordering from
@GwtCompatible(serializable = true) @Deprecated public static <T> Ordering<T> from(Ordering<T> ordering)
From source file:com.cloudera.oryx.ml.serving.als.MostPopularItems.java
@GET @Produces({ CSVMessageBodyWriter.TEXT_CSV, MediaType.APPLICATION_JSON }) public List<IDCount> get(@DefaultValue("10") @QueryParam("howMany") int howMany, @DefaultValue("0") @QueryParam("offset") int offset) { ALSServingModel model = getALSServingModel(); Map<String, Integer> itemCounts = model.getItemCounts(); Iterable<Pair<String, Integer>> countPairs = Iterables.transform(itemCounts.entrySet(), new Function<Map.Entry<String, Integer>, Pair<String, Integer>>() { @Override/* w w w .j a v a 2 s. c o m*/ public Pair<String, Integer> apply(Map.Entry<String, Integer> input) { return new Pair<>(input.getKey(), input.getValue()); } }); List<Pair<String, Integer>> allTopCountPairs = Ordering.from(PairComparators.<Integer>bySecond()) .greatestOf(countPairs, howMany + offset); List<Pair<String, Integer>> topCountPairs = selectedSublist(allTopCountPairs, howMany, offset); return Lists.transform(topCountPairs, new Function<Pair<String, Integer>, IDCount>() { @Override public IDCount apply(Pair<String, Integer> idCount) { return new IDCount(idCount.getFirst(), idCount.getSecond()); } }); }
From source file:com.gradleware.tooling.toolingmodel.repository.internal.HierarchyHelper.java
private <E extends T> ImmutableList<E> sort(List<E> elements) { return Ordering.from(this.comparator).immutableSortedCopy(elements); }
From source file:ec.util.completion.ext.QuickAutoCompletionSource.java
/** * Returns the master ordering used to sort values.<br>Default behavior uses * {@link #compare(java.lang.Object, java.lang.Object)}. * * @return a new ordering/*from w w w .java2 s . c o m*/ */ protected Ordering getSorter() { return Ordering.from(this); }
From source file:com.facebook.presto.util.IterableTransformer.java
public IterableTransformer<E> orderBy(Comparator<E> ordering) { return new IterableTransformer<>(Ordering.from(ordering).sortedCopy(iterable)); }
From source file:eu.lp0.cursus.ui.table.RaceAttendeesDatabaseColumn.java
public void setRace(Race race) { if (race != null) { pilots.replaceAll(Collections2.transform( Ordering.from(new PilotRaceNumberComparator()).sortedCopy(race.getAttendees().keySet()), PilotWrapper.getFunction())); } else {// www . jav a 2 s. c om pilots.replaceAll(Collections.<PilotWrapper>emptySet()); } }
From source file:com.google.transconsole.common.messages.Bundle.java
/** * @return a sorted immutable list of the Message objects in this bundle *///from w w w.j av a 2s . co m public List<T> getMessages() { return ImmutableList.copyOf(Ordering.from(new Comparator<T>() { public int compare(T m1, T m2) { return m1.getId().compareTo(m2.getId()); } }).sortedCopy(messages.values())); }
From source file:iterator.model.IFS.java
@Override public boolean add(Transform element) { if (element.getId() < 0) { element.setId(isEmpty() ? 1 : Ordering.from(IDENTITY).max(this).getId() + 1); element.setZIndex(isEmpty() ? 0 : Ordering.from(Z_ORDER).max(this).getZIndex() + 1); }/*from w ww. ja va 2s . c om*/ return super.add(element); }
From source file:com.esofthead.mycollab.module.project.ui.components.TimeTrackingDateOrderComponent.java
@Override protected Ordering<SimpleItemTimeLogging> sortEntries() { return Ordering.from(new DateComparator()).compound(new ProjectComparator()).compound(new UserComparator()); }
From source file:org.graylog2.messageprocessors.MessageFilterChainProcessor.java
@Inject public MessageFilterChainProcessor(MetricRegistry metricRegistry, Set<MessageFilter> filterRegistry, Journal journal, ServerStatus serverStatus) { this.metricRegistry = metricRegistry; this.journal = journal; this.serverStatus = serverStatus; // we need to keep this sorted properly, so that the filters run in the correct order this.filterRegistry = Ordering.from(new Comparator<MessageFilter>() { @Override//from w w w . j a v a 2 s.c o m public int compare(MessageFilter filter1, MessageFilter filter2) { return ComparisonChain.start().compare(filter1.getPriority(), filter2.getPriority()) .compare(filter1.getName(), filter2.getName()).result(); } }).immutableSortedCopy(filterRegistry); if (filterRegistry.size() == 0) throw new RuntimeException("Empty filter registry!"); this.filteredOutMessages = metricRegistry.meter(name(ProcessBufferProcessor.class, "filteredOutMessages")); }
From source file:springfox.documentation.spring.web.readers.operation.HandlerMethodResolver.java
@VisibleForTesting static Ordering<ResolvedMethod> byArgumentCount() { return Ordering.from(new Comparator<ResolvedMethod>() { @Override/*from ww w . ja va 2s .com*/ public int compare(ResolvedMethod first, ResolvedMethod second) { return Ints.compare(first.getArgumentCount(), second.getArgumentCount()); } }); }