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:
정보교 (Bogus Jung) 2025-02-21 22:24:58 +09:00 committed by GitHub
parent 64f88ae9ac
commit 8b43af2d33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 6 deletions

View File

@ -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

View File

@ -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()));

View File

@ -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()));

View File

@ -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);