Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code cleanups (intellij inspections). #12971

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static Object parse(String wkt) throws IOException, ParseException {
public static Object parseExpectedType(String wkt, final ShapeType shapeType)
throws IOException, ParseException {
try (StringReader reader = new StringReader(wkt)) {
// setup the tokenizer; configured to read words w/o numbers
// set up the tokenizer; configured to read words w/o numbers
StreamTokenizer tokenizer = new StreamTokenizer(reader);
tokenizer.resetSyntax();
tokenizer.wordChars('a', 'z');
Expand Down Expand Up @@ -110,7 +110,7 @@ private static double[] parsePoint(StreamTokenizer stream) throws IOException, P
return null;
}
double[] pt = new double[] {nextNumber(stream), nextNumber(stream)};
if (isNumberNext(stream) == true) {
if (isNumberNext(stream)) {
nextNumber(stream);
}
nextCloser(stream);
Expand Down Expand Up @@ -195,7 +195,7 @@ private static Line[] parseMultiLine(StreamTokenizer stream) throws IOException,
while (nextCloserOrComma(stream).equals(COMMA)) {
lines.add(parseLine(stream));
}
return lines.toArray(new Line[lines.size()]);
return lines.toArray(new Line[0]);
}

/** parses the hole of a polygon */
Expand Down Expand Up @@ -226,7 +226,7 @@ private static Polygon parsePolygon(StreamTokenizer stream) throws IOException,
return new Polygon(
lats.stream().mapToDouble(i -> i).toArray(),
lons.stream().mapToDouble(i -> i).toArray(),
holes.toArray(new Polygon[holes.size()]));
holes.toArray(new Polygon[0]));
}
return new Polygon(
lats.stream().mapToDouble(i -> i).toArray(), lons.stream().mapToDouble(i -> i).toArray());
Expand All @@ -244,7 +244,7 @@ private static Polygon[] parseMultiPolygon(StreamTokenizer stream)
while (nextCloserOrComma(stream).equals(COMMA)) {
polygons.add(parsePolygon(stream));
}
return polygons.toArray(new Polygon[polygons.size()]);
return polygons.toArray(new Polygon[0]);
}

/** parses an ENVELOPE */
Expand Down Expand Up @@ -274,7 +274,7 @@ private static Object[] parseGeometryCollection(StreamTokenizer stream)
while (nextCloserOrComma(stream).equals(COMMA)) {
geometries.add(parseGeometry(stream, null));
}
return geometries.toArray(new Object[geometries.size()]);
return geometries.toArray(new Object[0]);
}

/** next word in the stream */
Expand Down Expand Up @@ -355,7 +355,7 @@ private static String nextCloser(StreamTokenizer stream) throws IOException, Par

/** expects a comma as next token */
private static String nextComma(StreamTokenizer stream) throws IOException, ParseException {
if (nextWord(stream).equals(COMMA) == true) {
if (nextWord(stream).equals(COMMA)) {
return COMMA;
}
throw new ParseException(
Expand Down Expand Up @@ -404,7 +404,7 @@ public enum ShapeType {
ENVELOPE("envelope"); // not part of the actual WKB spec

private final String shapeName;
private static Map<String, ShapeType> shapeTypeMap = new HashMap<>();
private static final Map<String, ShapeType> shapeTypeMap = new HashMap<>();
private static final String BBOX = "BBOX";

static {
Expand All @@ -429,10 +429,9 @@ public String wktName() {

public static ShapeType forName(String shapename) {
String typename = shapename.toLowerCase(Locale.ROOT);
for (ShapeType type : values()) {
if (type.shapeName.equals(typename)) {
return type;
}
ShapeType type = shapeTypeMap.get(typename);
if (type != null) {
return type;
}
throw new IllegalArgumentException("unknown geo_shape [" + shapename + "]");
}
Expand Down
Loading