Refine search
/** * Returns a builder that creates immutable sorted multisets whose elements are ordered by the * reverse of their natural ordering. * * <p>Note: the type parameter {@code E} extends {@code Comparable<?>} rather than {@code * Comparable<? super E>} as a workaround for javac <a * href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468354">bug 6468354</a>. */ public static <E extends Comparable<?>> Builder<E> reverseOrder() { return new Builder<E>(Ordering.natural().reverse()); }
@JsonCreator public TimestampMinAggregatorFactory( @JsonProperty("name") String name, @JsonProperty("fieldName") String fieldName, @JsonProperty("timeFormat") String timeFormat ) { super(name, fieldName, timeFormat, Ordering.natural().reverse(), Long.MAX_VALUE); Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName"); }
/** * Returns a builder that creates immutable sorted multisets whose elements are ordered by the * reverse of their natural ordering. * * <p>Note: the type parameter {@code E} extends {@code Comparable<?>} rather than {@code * Comparable<? super E>} as a workaround for javac <a * href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468354">bug 6468354</a>. */ public static <E extends Comparable<?>> Builder<E> reverseOrder() { return new Builder<E>(Ordering.natural().reverse()); }
private static Ordering<ComponentDto> numericalMetricOrdering(boolean isAscending, @Nullable MetricDto metric, Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) { Ordering<Double> ordering = Ordering.natural(); if (!isAscending) { ordering = ordering.reverse(); } return ordering.nullsLast().onResultOf(new ComponentDtoToNumericalMeasureValue(metric, measuresByComponentUuidAndMetric)); }
private static Ordering<ComponentDto> levelMetricOrdering(boolean isAscending, @Nullable MetricDto metric, Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) { Ordering<Integer> ordering = Ordering.natural(); // inverse the order of org.sonar.api.measures.Metric.Level if (isAscending) { ordering = ordering.reverse(); } return ordering.nullsLast().onResultOf(new ComponentDtoToLevelIndex(metric, measuresByComponentUuidAndMetric)); }
public void testSameComparator() { assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet())); // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set. if (Maps.newTreeMap().keySet() instanceof SortedSet) { assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet())); } assertTrue( SortedIterables.hasSameComparator( Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse()))); }
private static Ordering<ComponentDto> numericalMetricPeriodOrdering(ComponentTreeRequest request, @Nullable MetricDto metric, Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) { Ordering<Double> ordering = Ordering.natural(); if (!request.getAsc()) { ordering = ordering.reverse(); } return ordering.nullsLast().onResultOf(new ComponentDtoToMeasureVariationValue(metric, measuresByComponentUuidAndMetric)); }
public void testReverse() { Ordering<Number> reverseOrder = numberOrdering.reverse(); Helpers.testComparator(reverseOrder, Integer.MAX_VALUE, 1, 0, -1, Integer.MIN_VALUE); new EqualsTester() .addEqualityGroup(reverseOrder, numberOrdering.reverse()) .addEqualityGroup(Ordering.natural().reverse()) .addEqualityGroup(Collections.reverseOrder()) .testEquals(); }