Skip to content

Commit f71f107

Browse files
committed
Polishing.
Reorder methods. Add since tag. Simplify assertions. Use diamond syntax. See: #3776 Original pull request: #3777.
1 parent 36e2d80 commit f71f107

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java

+19-18
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,31 @@ public class GeoJsonMultiPoint implements GeoJson<Iterable<Point>> {
3838

3939
private final List<Point> points;
4040

41+
/**
42+
* Creates a new {@link GeoJsonMultiPoint} for the given {@link Point}.
43+
*
44+
* @param point must not be {@literal null}.
45+
* @since 3.2.5
46+
*/
47+
public GeoJsonMultiPoint(Point point) {
48+
49+
Assert.notNull(point, "Point must not be null!");
50+
51+
this.points = new ArrayList<>();
52+
this.points.add(point);
53+
}
54+
4155
/**
4256
* Creates a new {@link GeoJsonMultiPoint} for the given {@link Point}s.
4357
*
44-
* @param points points must not be {@literal null} and have at least 1 entry.
58+
* @param points points must not be {@literal null} and not empty
4559
*/
4660
public GeoJsonMultiPoint(List<Point> points) {
4761

48-
Assert.notNull(points, "Points must not be null.");
49-
Assert.isTrue(points.size() >= 1, "Minimum of 1 Point required.");
62+
Assert.notNull(points, "Points must not be null!");
63+
Assert.notEmpty(points, "Points must contain at least one point!");
5064

51-
this.points = new ArrayList<Point>(points);
65+
this.points = new ArrayList<>(points);
5266
}
5367

5468
/**
@@ -64,25 +78,12 @@ public GeoJsonMultiPoint(Point first, Point second, Point... others) {
6478
Assert.notNull(second, "Second point must not be null!");
6579
Assert.notNull(others, "Additional points must not be null!");
6680

67-
this.points = new ArrayList<Point>();
81+
this.points = new ArrayList<>();
6882
this.points.add(first);
6983
this.points.add(second);
7084
this.points.addAll(Arrays.asList(others));
7185
}
7286

73-
/**
74-
* Creates a new {@link GeoJsonMultiPoint} for the given {@link Point}.
75-
*
76-
* @param point must not be {@literal null}.
77-
*/
78-
public GeoJsonMultiPoint(Point point) {
79-
80-
Assert.notNull(point, "First point must not be null!");
81-
82-
this.points = new ArrayList<Point>();
83-
this.points.add(point);
84-
}
85-
8687
/*
8788
* (non-Javadoc)
8889
* @see org.springframework.data.mongodb.core.geo.GeoJson#getType()

0 commit comments

Comments
 (0)