Skip to content

Commit 04997b1

Browse files
committed
Discourage Ordering.min(E, E) and max(E, E) in favor of Comparators.min(E, E, Comparator) and max(E, E, Comparator).
RELNOTES=Discourage the use of Ordering.min(E, E) and max(E, E). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=315373918
1 parent 958186c commit 04997b1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

android/guava/src/com/google/common/collect/Ordering.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ public <E extends T> E min(Iterable<E> iterable) {
582582
* <p><b>Implementation note:</b> this method is invoked by the default implementations of the
583583
* other {@code min} overloads, so overriding it will affect their behavior.
584584
*
585-
* <p><b>Java 8 users:</b> Use {@code Collections.min(Arrays.asList(a, b), thisComparator)}
586-
* instead (but note that it does not guarantee which tied minimum element is returned).
585+
* <p><b>Note:</b> Consider using {@code Comparators.min(a, b, thisComparator)} instead. If {@code
586+
* thisComparator} is {@link Ordering#natural}, then use {@code Comparators.min(a, b)}.
587587
*
588588
* @param a value to compare, returned if less than or equal to b.
589589
* @param b value to compare.
@@ -668,8 +668,8 @@ public <E extends T> E max(Iterable<E> iterable) {
668668
* <p><b>Implementation note:</b> this method is invoked by the default implementations of the
669669
* other {@code max} overloads, so overriding it will affect their behavior.
670670
*
671-
* <p><b>Java 8 users:</b> Use {@code Collections.max(Arrays.asList(a, b), thisComparator)}
672-
* instead (but note that it does not guarantee which tied maximum element is returned).
671+
* <p><b>Note:</b> Consider using {@code Comparators.max(a, b, thisComparator)} instead. If {@code
672+
* thisComparator} is {@link Ordering#natural}, then use {@code Comparators.max(a, b)}.
673673
*
674674
* @param a value to compare, returned if greater than or equal to b.
675675
* @param b value to compare.

guava/src/com/google/common/collect/Ordering.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ public <E extends T> E min(Iterable<E> iterable) {
582582
* <p><b>Implementation note:</b> this method is invoked by the default implementations of the
583583
* other {@code min} overloads, so overriding it will affect their behavior.
584584
*
585-
* <p><b>Java 8 users:</b> Use {@code Collections.min(Arrays.asList(a, b), thisComparator)}
586-
* instead (but note that it does not guarantee which tied minimum element is returned).
585+
* <p><b>Note:</b> Consider using {@code Comparators.min(a, b, thisComparator)} instead. If {@code
586+
* thisComparator} is {@link Ordering#natural}, then use {@code Comparators.min(a, b)}.
587587
*
588588
* @param a value to compare, returned if less than or equal to b.
589589
* @param b value to compare.
@@ -668,8 +668,8 @@ public <E extends T> E max(Iterable<E> iterable) {
668668
* <p><b>Implementation note:</b> this method is invoked by the default implementations of the
669669
* other {@code max} overloads, so overriding it will affect their behavior.
670670
*
671-
* <p><b>Java 8 users:</b> Use {@code Collections.max(Arrays.asList(a, b), thisComparator)}
672-
* instead (but note that it does not guarantee which tied maximum element is returned).
671+
* <p><b>Note:</b> Consider using {@code Comparators.max(a, b, thisComparator)} instead. If {@code
672+
* thisComparator} is {@link Ordering#natural}, then use {@code Comparators.max(a, b)}.
673673
*
674674
* @param a value to compare, returned if greater than or equal to b.
675675
* @param b value to compare.

0 commit comments

Comments
 (0)