DATACMNS-1050 - Encapsulate boundaries in value objects for Range.
We now encapsulate a boundary in Range within a Bound value object. Bound consists of a value and whether the value is inclusive or exclusive. Boundaries without a value are unbounded. We introduced factory methods for Range and Boundary creation using primitives and a builder to build a Range. Range<Long> range = Range.unbounded(); Range<Integer> range = Range.from(Bound.inclusive(10)).to(Bound.inclusive(20)); Range<Integer> range = Range.of(Bound.inclusive(10), Bound.inclusive(20)); Original pull request: #121.
This commit is contained in:
committed by
Oliver Gierke
parent
233fde36b5
commit
22dc91b68f
@@ -21,6 +21,7 @@ import static org.springframework.data.geo.Metrics.*;
|
||||
import org.assertj.core.data.Offset;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.domain.Range.Bound;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ import org.springframework.util.SerializationUtils;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class DistanceUnitTests {
|
||||
|
||||
@@ -129,8 +131,8 @@ public class DistanceUnitTests {
|
||||
Range<Distance> range = Distance.between(twoKilometers, tenKilometers);
|
||||
|
||||
assertThat(range).isNotNull();
|
||||
assertThat(range.getLowerBound()).isEqualTo(twoKilometers);
|
||||
assertThat(range.getUpperBound()).isEqualTo(tenKilometers);
|
||||
assertThat(range.getLowerBound()).isEqualTo(Bound.inclusive(twoKilometers));
|
||||
assertThat(range.getUpperBound()).isEqualTo(Bound.inclusive(tenKilometers));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
@@ -142,8 +144,8 @@ public class DistanceUnitTests {
|
||||
Range<Distance> range = Distance.between(2, KILOMETERS, 10, KILOMETERS);
|
||||
|
||||
assertThat(range).isNotNull();
|
||||
assertThat(range.getLowerBound()).isEqualTo(twoKilometers);
|
||||
assertThat(range.getUpperBound()).isEqualTo(tenKilometers);
|
||||
assertThat(range.getLowerBound()).isEqualTo(Bound.inclusive(twoKilometers));
|
||||
assertThat(range.getUpperBound()).isEqualTo(Bound.inclusive(tenKilometers));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
|
||||
Reference in New Issue
Block a user