Replace the if/else chain with a switch
@@ -53,29 +53,25 @@ public final class GeometryUtils
public static GeometryTypeName valueOf(String type)
{
- if (type.equals(POINT)) {
+ switch (type) {
+ case POINT:
return GeometryTypeName.POINT;
- }
- else if (type.equals(MULTI_POINT)) {
+ case MULTI_POINT:
return GeometryTypeName.MULTI_POINT;
- }
- else if (type.equals(LINE_STRING)) {
+ case LINE_STRING:
return GeometryTypeName.LINE_STRING;
- }
- else if (type.equals(MULTI_LINE_STRING)) {
+ case MULTI_LINE_STRING:
return GeometryTypeName.MULTI_LINE_STRING;
- }
- else if (type.equals(POLYGON)) {
+ case POLYGON:
return GeometryTypeName.POLYGON;
- }
- else if (type.equals(MULTI_POLYGON)) {
+ case MULTI_POLYGON:
return GeometryTypeName.MULTI_POLYGON;
- }
- else if (type.equals(GEOMETRY_COLLECTION)) {
+ case GEOMETRY_COLLECTION:
return GeometryTypeName.GEOMETRY_COLLECTION;
- }
+ default:
throw new IllegalArgumentException("Invalid Geometry Type: " + type);
}
+ }
public static OGCGeometry deserialize(Slice shape)
{
