commit
a5dfae0dc3
|
@ -20,11 +20,7 @@ public class CollectorsUnitTest {
|
||||||
public void whenTeeing_ItShouldCombineTheResultsAsExpected() {
|
public void whenTeeing_ItShouldCombineTheResultsAsExpected() {
|
||||||
List<Integer> numbers = Arrays.asList(42, 4, 2, 24);
|
List<Integer> numbers = Arrays.asList(42, 4, 2, 24);
|
||||||
Range range = numbers.stream()
|
Range range = numbers.stream()
|
||||||
.collect(teeing(
|
.collect(teeing(minBy(Integer::compareTo), maxBy(Integer::compareTo), (min, max) -> new Range(min.orElse(null), max.orElse(null))));
|
||||||
minBy(Integer::compareTo),
|
|
||||||
maxBy(Integer::compareTo),
|
|
||||||
(min, max) -> new Range(min.orElse(null), max.orElse(null))
|
|
||||||
));
|
|
||||||
|
|
||||||
assertThat(range).isEqualTo(new Range(2, 42));
|
assertThat(range).isEqualTo(new Range(2, 42));
|
||||||
}
|
}
|
||||||
|
@ -54,11 +50,12 @@ public class CollectorsUnitTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o)
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
Range range = (Range) o;
|
Range range = (Range) o;
|
||||||
return Objects.equals(getMin(), range.getMin()) &&
|
return Objects.equals(getMin(), range.getMin()) && Objects.equals(getMax(), range.getMax());
|
||||||
Objects.equals(getMax(), range.getMax());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,10 +65,7 @@ public class CollectorsUnitTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Range{" +
|
return "Range{" + "min=" + min + ", max=" + max + '}';
|
||||||
"min=" + min +
|
|
||||||
", max=" + max +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue