Skip to content

Commit 082c7c6

Browse files
committed
Lang: Remove redundant generic types
new ArrayList<Shape> with new ArrayList<> Also removed one "dead store".
1 parent 80f5d3f commit 082c7c6

File tree

16 files changed

+29
-30
lines changed

16 files changed

+29
-30
lines changed

src/main/java/org/locationtech/spatial4j/context/SpatialContextFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public class SpatialContextFactory {
6969

7070
public Class<? extends ShapeFactory> shapeFactoryClass = ShapeFactoryImpl.class;
7171
public Class<? extends BinaryCodec> binaryCodecClass = BinaryCodec.class;
72-
public final List<Class<? extends ShapeReader>> readers = new ArrayList<Class<? extends ShapeReader>>();
73-
public final List<Class<? extends ShapeWriter>> writers = new ArrayList<Class<? extends ShapeWriter>>();
72+
public final List<Class<? extends ShapeReader>> readers = new ArrayList<>();
73+
public final List<Class<? extends ShapeWriter>> writers = new ArrayList<>();
7474
public boolean hasFormatConfig = false;
7575

7676
public SpatialContextFactory() {
@@ -218,7 +218,7 @@ protected void initFormats() {
218218
public SupportedFormats makeFormats(SpatialContext ctx) {
219219
checkDefaultFormats(); // easy to override
220220

221-
List<ShapeReader> read = new ArrayList<ShapeReader>(readers.size());
221+
List<ShapeReader> read = new ArrayList<>(readers.size());
222222
for (Class<? extends ShapeReader> clazz : readers) {
223223
try {
224224
read.add(makeClassInstance(clazz, ctx, this));
@@ -227,7 +227,7 @@ public SupportedFormats makeFormats(SpatialContext ctx) {
227227
}
228228
}
229229

230-
List<ShapeWriter> write = new ArrayList<ShapeWriter>(writers.size());
230+
List<ShapeWriter> write = new ArrayList<>(writers.size());
231231
for (Class<? extends ShapeWriter> clazz : writers) {
232232
try {
233233
write.add(makeClassInstance(clazz, ctx, this));

src/main/java/org/locationtech/spatial4j/io/BinaryCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void writeCircle(DataOutput dataOutput, Circle c) throws IOException {
145145
public ShapeCollection readCollection(DataInput dataInput) throws IOException {
146146
byte type = dataInput.readByte();
147147
int size = dataInput.readInt();
148-
ArrayList<Shape> shapes = new ArrayList<Shape>(size);
148+
ArrayList<Shape> shapes = new ArrayList<>(size);
149149
for (int i = 0; i < size; i++) {
150150
if (type == 0) {
151151
shapes.add(readShape(dataInput));

src/main/java/org/locationtech/spatial4j/io/GeoJSONReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ protected Shape readShape(JSONParser parser) throws IOException, ParseException
249249
readUntilEvent(parser, JSONParser.OBJECT_END);
250250
return shape;
251251
} else if ("geometries".equals(key)) {
252-
List<Shape> shapes = new ArrayList<Shape>();
252+
List<Shape> shapes = new ArrayList<>();
253253
int sub = parser.nextEvent();
254254
while (sub != JSONParser.EOF) {
255255
if (sub == JSONParser.OBJECT_START) {

src/main/java/org/locationtech/spatial4j/io/PolyshapeReader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public final Shape read(Reader r) throws ParseException, IOException
9292

9393
if(lastShape!=null) {
9494
if(shapes==null) {
95-
shapes = new ArrayList<Shape>();
95+
shapes = new ArrayList<>();
9696
}
9797
shapes.add(lastShape);
9898
}
@@ -174,7 +174,6 @@ protected Shape readPolygon(XReader reader) throws IOException {
174174
reader.readPoints(polyBuilder);
175175

176176
if(!reader.isDone() && reader.peek()==PolyshapeWriter.KEY_ARG_START) {
177-
List<LinearRing> list = new ArrayList<LinearRing>();
178177
while(reader.isEvent() && reader.peek()==PolyshapeWriter.KEY_ARG_START) {
179178
reader.readKey(); // eat the event;
180179
reader.readPoints(polyBuilder.hole()).endHole();

src/main/java/org/locationtech/spatial4j/shape/ShapeCollection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public boolean hasArea() {
9999

100100
@Override
101101
public ShapeCollection getBuffered(double distance, SpatialContext ctx) {
102-
List<Shape> bufColl = new ArrayList<Shape>(size());
102+
List<Shape> bufColl = new ArrayList<>(size());
103103
for (Shape shape : shapes) {
104104
bufColl.add(shape.getBuffered(distance, ctx));
105105
}

src/main/java/org/locationtech/spatial4j/shape/impl/BufferedLineString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public BufferedLineString(List<Point> points, double buf, boolean expandBufForLo
5959
if (points.isEmpty()) {
6060
this.segments = ctx.makeCollection(Collections.<BufferedLine>emptyList());
6161
} else {
62-
List<BufferedLine> segments = new ArrayList<BufferedLine>(points.size() - 1);
62+
List<BufferedLine> segments = new ArrayList<>(points.size() - 1);
6363

6464
Point prevPoint = null;
6565
for (Point point : points) {

src/main/java/org/locationtech/spatial4j/shape/jts/JtsGeometry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ private static Geometry cutUnwrappedGeomInto360(Geometry geom) {
573573
return geom;
574574
assert geom.isValid() : "geom";
575575

576-
List<Geometry> geomList = new ArrayList<Geometry>();
576+
List<Geometry> geomList = new ArrayList<>();
577577
//page 0 is the standard -180 to 180 range
578578
int startPage = (int) Math.floor((geomEnv.getMinX() + 180) / 360);
579579
for (int page = startPage; true; page++) {

src/test/java/org/locationtech/spatial4j/TestLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class TestLog extends TestRuleAdapter {
2323

2424
//TODO does this need to be threadsafe (such as via thread-local state)?
25-
private static ArrayList<LogEntry> logStack = new ArrayList<LogEntry>();
25+
private static ArrayList<LogEntry> logStack = new ArrayList<>();
2626
private static final int MAX_LOGS = 1000;
2727

2828
public static final TestLog instance = new TestLog();

src/test/java/org/locationtech/spatial4j/context/SpatialContextFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void tearDown() {
3636
}
3737

3838
private SpatialContext call(String... argsStr) {
39-
Map<String,String> args = new HashMap<String,String>();
39+
Map<String,String> args = new HashMap<>();
4040
for (int i = 0; i < argsStr.length; i+=2) {
4141
String key = argsStr[i];
4242
String val = argsStr[i+1];

src/test/java/org/locationtech/spatial4j/io/WKTWriterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void testToStringOnEmptyPoint() throws Exception {
3030
@Test
3131
public void testToStringOnEmptyShapeCollection() throws Exception {
3232
ShapeWriter writer = ctx.getFormats().getWktWriter();
33-
ShapeCollection<Point> emptyCollection = ctx.makeCollection(new ArrayList<Point>());
33+
ShapeCollection<Point> emptyCollection = ctx.makeCollection(new ArrayList<>());
3434

3535
assertEquals("GEOMETRYCOLLECTION EMPTY", writer.toString(emptyCollection));
3636
}

0 commit comments

Comments
 (0)