mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 03:52:10 +00:00
optimize capacity & add assert messages in GeoJson.
Original Pull Request #3064 Closes #3063 Signed-off-by: 정보교 (Bogus Jung) <bogusjung0317@gmail.com>
This commit is contained in:
parent
64f88ae9ac
commit
8b43af2d33
@ -21,7 +21,7 @@ import org.springframework.data.elasticsearch.core.document.Document;
|
||||
|
||||
/**
|
||||
* Interface definition for structures defined in <a href="https://geojson.org">GeoJSON</a>
|
||||
* format. copied from Spring Data Mongodb
|
||||
* format. copied from Spring Data Mongodb
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 1.7
|
||||
|
@ -69,7 +69,7 @@ public class GeoJsonLineString implements GeoJson<Iterable<Point>> {
|
||||
Assert.notNull(second, "Second point must not be null!");
|
||||
Assert.notNull(others, "Additional points must not be null!");
|
||||
|
||||
List<Point> points = new ArrayList<>();
|
||||
List<Point> points = new ArrayList<>(2 + others.length);
|
||||
points.add(first);
|
||||
points.add(second);
|
||||
points.addAll(Arrays.asList(others));
|
||||
@ -103,7 +103,7 @@ public class GeoJsonLineString implements GeoJson<Iterable<Point>> {
|
||||
Assert.notNull(second, "Second point must not be null!");
|
||||
Assert.notNull(others, "Additional points must not be null!");
|
||||
|
||||
List<Point> points = new ArrayList<>();
|
||||
List<Point> points = new ArrayList<>(2 + others.length);
|
||||
points.add(GeoPoint.toPoint(first));
|
||||
points.add(GeoPoint.toPoint(second));
|
||||
points.addAll(Arrays.stream(others).map(GeoPoint::toPoint).collect(Collectors.toList()));
|
||||
|
@ -69,7 +69,7 @@ public class GeoJsonMultiPoint implements GeoJson<Iterable<Point>> {
|
||||
Assert.notNull(second, "Second point must not be null!");
|
||||
Assert.notNull(others, "Additional points must not be null!");
|
||||
|
||||
List<Point> points = new ArrayList<>();
|
||||
List<Point> points = new ArrayList<>(2 + others.length);
|
||||
points.add(first);
|
||||
points.add(second);
|
||||
points.addAll(Arrays.asList(others));
|
||||
@ -103,7 +103,7 @@ public class GeoJsonMultiPoint implements GeoJson<Iterable<Point>> {
|
||||
Assert.notNull(second, "Second point must not be null!");
|
||||
Assert.notNull(others, "Additional points must not be null!");
|
||||
|
||||
List<Point> points = new ArrayList<>();
|
||||
List<Point> points = new ArrayList<>(2 + others.length);
|
||||
points.add(GeoPoint.toPoint(first));
|
||||
points.add(GeoPoint.toPoint(second));
|
||||
points.addAll(Arrays.stream(others).map(GeoPoint::toPoint).collect(Collectors.toList()));
|
||||
|
@ -189,7 +189,13 @@ public class GeoJsonPolygon implements GeoJson<Iterable<GeoJsonLineString>> {
|
||||
@SafeVarargs
|
||||
private static <T> List<T> asList(T first, T second, T third, T fourth, T... others) {
|
||||
|
||||
ArrayList<T> result = new ArrayList<>(3 + others.length);
|
||||
Assert.notNull(first, "First element must not be null!");
|
||||
Assert.notNull(second, "Second element must not be null!");
|
||||
Assert.notNull(third, "Third element must not be null!");
|
||||
Assert.notNull(fourth, "Fourth element must not be null!");
|
||||
Assert.notNull(others, "Additional elements must not be null!");
|
||||
|
||||
ArrayList<T> result = new ArrayList<>(4 + others.length);
|
||||
|
||||
result.add(first);
|
||||
result.add(second);
|
||||
|
Loading…
x
Reference in New Issue
Block a user