Merge pull request #6577 from eugenp/fix-formatting

formatting
This commit is contained in:
Loredana Crusoveanu 2019-03-23 21:11:34 +02:00 committed by GitHub
commit a5dfae0dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 88 deletions

View File

@ -1,48 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>core-java-12</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-12</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>core-java-12</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-12</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source.version}</source>
<target>${maven.compiler.target.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source.version}</source>
<target>${maven.compiler.target.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source.version>12</maven.compiler.source.version>
<maven.compiler.target.version>12</maven.compiler.target.version>
<assertj.version>3.6.1</assertj.version>
</properties>
<properties>
<maven.compiler.source.version>12</maven.compiler.source.version>
<maven.compiler.target.version>12</maven.compiler.target.version>
<assertj.version>3.6.1</assertj.version>
</properties>
</project>

View File

@ -16,62 +16,56 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class CollectorsUnitTest {
@Test
public void whenTeeing_ItShouldCombineTheResultsAsExpected() {
List<Integer> numbers = Arrays.asList(42, 4, 2, 24);
Range range = numbers.stream()
.collect(teeing(
minBy(Integer::compareTo),
maxBy(Integer::compareTo),
(min, max) -> new Range(min.orElse(null), max.orElse(null))
));
@Test
public void whenTeeing_ItShouldCombineTheResultsAsExpected() {
List<Integer> numbers = Arrays.asList(42, 4, 2, 24);
Range range = numbers.stream()
.collect(teeing(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));
}
/**
* Represents a closed range of numbers between {@link #min} and
* {@link #max}, both inclusive.
*/
private static class Range {
/**
* Represents a closed range of numbers between {@link #min} and
* {@link #max}, both inclusive.
*/
private static class Range {
private final Integer min;
private final Integer min;
private final Integer max;
private final Integer max;
Range(Integer min, Integer max) {
this.min = min;
this.max = max;
}
Range(Integer min, Integer max) {
this.min = min;
this.max = max;
}
Integer getMin() {
return min;
}
Integer getMin() {
return min;
}
Integer getMax() {
return max;
}
Integer getMax() {
return max;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Range range = (Range) o;
return Objects.equals(getMin(), range.getMin()) &&
Objects.equals(getMax(), range.getMax());
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Range range = (Range) o;
return Objects.equals(getMin(), range.getMin()) && Objects.equals(getMax(), range.getMax());
}
@Override
public int hashCode() {
return Objects.hash(getMin(), getMax());
}
@Override
public int hashCode() {
return Objects.hash(getMin(), getMax());
}
@Override
public String toString() {
return "Range{" +
"min=" + min +
", max=" + max +
'}';
}
}
@Override
public String toString() {
return "Range{" + "min=" + min + ", max=" + max + '}';
}
}
}