changeset 6438:76facba329a1

Rename min/maxBy to min/max
author briangoetz
date Mon, 19 Nov 2012 11:37:43 -0500
parents 1359dedd5475
children ef7e5c6f01f4
files src/share/classes/java/util/stream/ReferencePipeline.java src/share/classes/java/util/stream/Stream.java test-ng/tests/org/openjdk/tests/java/util/stream/op/MinMaxByTest.java
diffstat 3 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Mon Nov 19 17:18:19 2012 +0100
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Mon Nov 19 11:37:43 2012 -0500
@@ -198,12 +198,12 @@
     }
 
     @Override
-    public Optional<U> minBy(Comparator<? super U> comparator) {
+    public Optional<U> min(Comparator<? super U> comparator) {
         return reduce((a, b) -> comparator.compare(a, b) <= 0 ? a : b);
     }
 
     @Override
-    public Optional<U> maxBy(Comparator<? super U> comparator) {
+    public Optional<U> max(Comparator<? super U> comparator) {
         return reduce((a, b) -> comparator.compare(a, b) >= 0 ? a : b);
     }
 }
--- a/src/share/classes/java/util/stream/Stream.java	Mon Nov 19 17:18:19 2012 +0100
+++ b/src/share/classes/java/util/stream/Stream.java	Mon Nov 19 11:37:43 2012 -0500
@@ -125,9 +125,9 @@
                Combiner<U, T, U> reducer,
                BinaryOperator<U> combiner);
 
-    Optional<T> maxBy(Comparator<? super T> comparator);
+    Optional<T> max(Comparator<? super T> comparator);
 
-    Optional<T> minBy(Comparator<? super T> comparator);
+    Optional<T> min(Comparator<? super T> comparator);
 
     boolean anyMatch(Predicate<? super T> predicate);
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/MinMaxByTest.java	Mon Nov 19 17:18:19 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/MinMaxByTest.java	Mon Nov 19 11:37:43 2012 -0500
@@ -39,15 +39,15 @@
 @Test
 public class MinMaxByTest extends OpTestCase {
     public void testMinBy() {
-        assertTrue(!countTo(0).stream().minBy(Integer::compare).isPresent());
-        assertTrue(!countTo(0).stream().maxBy(Integer::compare).isPresent());
-        assertEquals(1, (int) countTo(1000).stream().minBy(Integer::compare).get());
-        assertEquals(1000, (int) countTo(1000).stream().maxBy(Integer::compare).get());
+        assertTrue(!countTo(0).stream().min(Integer::compare).isPresent());
+        assertTrue(!countTo(0).stream().max(Integer::compare).isPresent());
+        assertEquals(1, (int) countTo(1000).stream().min(Integer::compare).get());
+        assertEquals(1000, (int) countTo(1000).stream().max(Integer::compare).get());
     }
 
     @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
     public void testOps(String name, StreamTestData<Integer> data) {
-        exerciseTerminalOps(data, s -> s.minBy(Integer::compare));
-        exerciseTerminalOps(data, s -> s.maxBy(Integer::compare));
+        exerciseTerminalOps(data, s -> s.min(Integer::compare));
+        exerciseTerminalOps(data, s -> s.max(Integer::compare));
     }
 }