olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [39/51] [abbrv] olingo-odata4 git commit: [OLINGO-???] less use of reflection in equals() and hashCode()
Date Mon, 25 Jan 2016 20:31:19 GMT
[OLINGO-???] less use of reflection in equals() and hashCode()

Signed-off-by: Christian Amend <christian.amend@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/26f7d2a6
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/26f7d2a6
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/26f7d2a6

Branch: refs/heads/OLINGO-832_StreamSerializerPoC
Commit: 26f7d2a6b1ddf295d0133d78022b87391c98f48d
Parents: a283bdd
Author: Klaus Straubinger <klaus.straubinger@sap.com>
Authored: Fri Jan 15 16:08:27 2016 +0100
Committer: Christian Amend <christian.amend@sap.com>
Committed: Mon Jan 18 13:36:52 2016 +0100

----------------------------------------------------------------------
 .../commons/api/edm/FullQualifiedName.java      | 19 ++----
 .../commons/api/edm/geo/ComposedGeospatial.java | 32 ++++++++-
 .../olingo/commons/api/edm/geo/Geospatial.java  | 31 ++-------
 .../api/edm/geo/GeospatialCollection.java       | 10 ++-
 .../olingo/commons/api/edm/geo/LineString.java  |  8 +--
 .../commons/api/edm/geo/MultiLineString.java    |  8 +--
 .../olingo/commons/api/edm/geo/MultiPoint.java  |  8 +--
 .../commons/api/edm/geo/MultiPolygon.java       |  8 +--
 .../olingo/commons/api/edm/geo/Point.java       | 72 ++++++++++++++------
 .../olingo/commons/api/edm/geo/Polygon.java     | 38 ++++++++---
 .../apache/olingo/commons/api/edm/geo/SRID.java | 49 +++++--------
 11 files changed, 150 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
index 9f83d42..de0325e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
@@ -28,7 +28,6 @@ public final class FullQualifiedName implements Serializable {
   private static final long serialVersionUID = -4063629050858999076L;
 
   private final String namespace;
-
   private final String name;
 
   private final String fqn;
@@ -90,24 +89,14 @@ public final class FullQualifiedName implements Serializable {
       return false;
     }
 
-    FullQualifiedName that = (FullQualifiedName) o;
-
-    if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) {
-      return false;
-    }
-    if (name != null ? !name.equals(that.name) : that.name != null) {
-      return false;
-    }
-    return !(fqn != null ? !fqn.equals(that.fqn) : that.fqn != null);
-
+    final FullQualifiedName that = (FullQualifiedName) o;
+    return (namespace == null ? that.namespace == null : namespace.equals(that.namespace))
+        && (name == null ? that.name == null : name.equals(that.name));
   }
 
   @Override
   public int hashCode() {
-    int result = namespace != null ? namespace.hashCode() : 0;
-    result = 31 * result + (name != null ? name.hashCode() : 0);
-    result = 31 * result + (fqn != null ? fqn.hashCode() : 0);
-    return result;
+    return fqn == null ? 0 : fqn.hashCode();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
index f7e9f3d..0120a78 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
@@ -22,15 +22,13 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
- /**
+/**
  * Abstract base class for all Geometries that are composed out of other geospatial elements.
  *
  * @param <T> Type of the contained geospatial elements
  */
 public abstract class ComposedGeospatial<T extends Geospatial> extends Geospatial implements
Iterable<T> {
 
-  private static final long serialVersionUID = 8796254901098541307L;
-
   protected final List<T> geospatials;
 
   protected ComposedGeospatial(final Dimension dimension, final Type type, final SRID srid,
@@ -56,4 +54,32 @@ public abstract class ComposedGeospatial<T extends Geospatial> extends
Geospatia
   public boolean isEmpty() {
     return geospatials.isEmpty();
   }
+
+  @Override
+  public boolean equals(final Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    final ComposedGeospatial<?> other = (ComposedGeospatial<?>) o;
+    return dimension == other.dimension
+        && (srid == null ? other.srid == null : srid.equals(other.srid))
+        && geospatials.equals(other.geospatials);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = dimension == null ? 0 : dimension.hashCode();
+    result = 31 * result + (srid == null ? 0 : srid.hashCode());
+    result = 31 * result + geospatials.hashCode();
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    return geospatials.toString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
index 539196c..63d8b3f 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
@@ -18,21 +18,13 @@
  */
 package org.apache.olingo.commons.api.edm.geo;
 
-import java.io.Serializable;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 
 /**
  * Base class for all geospatial info.
  */
-public abstract class Geospatial implements Serializable {
+public abstract class Geospatial {
 
-  private static final long serialVersionUID = 5409612902190067390L;
-  
   /**
    * Dimension of the geospatial type
    */
@@ -46,7 +38,7 @@ public abstract class Geospatial implements Serializable {
      */
     GEOGRAPHY
   }
-  
+
   /**
    * Type of the geospatial type
    */
@@ -122,7 +114,7 @@ public abstract class Geospatial implements Serializable {
    * @return type.
    * @see Type
    */
-  public Type getType() {
+  public Type getGeoType() {
     return type;
   }
 
@@ -134,25 +126,10 @@ public abstract class Geospatial implements Serializable {
   public SRID getSrid() {
     return srid;
   }
-  
+
   /**
    * Returns the {@link EdmPrimitiveTypeKind}
    * @return Edm primitve type kind
    */
   public abstract EdmPrimitiveTypeKind getEdmPrimitiveTypeKind();
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
index e46aea2..4ac4a27 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
@@ -27,10 +27,8 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  */
 public class GeospatialCollection extends ComposedGeospatial<Geospatial> {
 
-  private static final long serialVersionUID = -9181547636133878977L;
-  
   /**
-   * Creates a new collection of geospatial types
+   * Creates a new collection of geospatial types.
    * @param dimension     Dimension of the collection
    * @param srid          SRID Value
    * @param geospatials   Members of the collection
@@ -41,8 +39,8 @@ public class GeospatialCollection extends ComposedGeospatial<Geospatial>
{
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyCollection
-            : EdmPrimitiveTypeKind.GeometryCollection;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyCollection :
+        EdmPrimitiveTypeKind.GeometryCollection;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java
index af2e13e..38e4573 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java
@@ -28,8 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  */
 public class LineString extends ComposedGeospatial<Point> {
 
-  private static final long serialVersionUID = 3207958185407535907L;
-  
   /**
    * Creates a new LineString
    * @param dimension     Dimension of the LineString
@@ -42,8 +40,8 @@ public class LineString extends ComposedGeospatial<Point> {
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyLineString
-            : EdmPrimitiveTypeKind.GeometryLineString;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyLineString :
+        EdmPrimitiveTypeKind.GeometryLineString;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java
index f8796b6..6bd88b2 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java
@@ -28,8 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  */
 public class MultiLineString extends ComposedGeospatial<LineString> {
 
-  private static final long serialVersionUID = -5042414471218124125L;
-  
   /**
    * Creates a new MultiLineString
    * 
@@ -43,9 +41,9 @@ public class MultiLineString extends ComposedGeospatial<LineString>
{
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyMultiLineString
-            : EdmPrimitiveTypeKind.GeometryMultiLineString;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyMultiLineString :
+        EdmPrimitiveTypeKind.GeometryMultiLineString;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java
index 8a38a73..8d23dcc 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java
@@ -28,8 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  */
 public class MultiPoint extends ComposedGeospatial<Point> {
 
-  private static final long serialVersionUID = 4951011255142116129L;
-  
   /**
    * Creates a new collection of points
    * @param dimension   Dimension of the points
@@ -42,9 +40,9 @@ public class MultiPoint extends ComposedGeospatial<Point> {
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyMultiPoint
-            : EdmPrimitiveTypeKind.GeometryMultiPoint;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyMultiPoint :
+        EdmPrimitiveTypeKind.GeometryMultiPoint;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java
index d39c3a1..8fae3d7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java
@@ -28,8 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  */
 public class MultiPolygon extends ComposedGeospatial<Polygon> {
 
-  private static final long serialVersionUID = -160184788048512883L;
-  
   /**
    * Creates a collection of polygons
    * 
@@ -43,8 +41,8 @@ public class MultiPolygon extends ComposedGeospatial<Polygon> {
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyMultiPolygon
-            : EdmPrimitiveTypeKind.GeometryMultiPolygon;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyMultiPolygon :
+        EdmPrimitiveTypeKind.GeometryMultiPolygon;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
index 0a79622..fa0ff9e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
@@ -21,15 +21,11 @@ package org.apache.olingo.commons.api.edm.geo;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 
 /**
- * Represents a point 
- * 
- * Either Edm.GeographyPoint or Edm.GeometryPoint
+ * Represents a point, either Edm.GeographyPoint or Edm.GeometryPoint.
  *
  */
 public class Point extends Geospatial {
 
-  private static final long serialVersionUID = 4917380107331557828L;
-
   /**
    * The X coordinate of the point. In most long/lat systems, this is the longitude.
    */
@@ -47,41 +43,40 @@ public class Point extends Geospatial {
   private double z;
 
   /**
-   * Creates a new point
-   * 
+   * Creates a new point.
    * @param dimension   Dimension of the point
    * @param srid        SRID value
    */
   public Point(final Dimension dimension, final SRID srid) {
     super(dimension, Type.POINT, srid);
   }
-  
+
   /**
-   * Returns the x coordinate
+   * Returns the x coordinate.
    * @return x coordinate
    */
   public double getX() {
     return x;
   }
-  
+
   /**
-   * Sets the x coordinate
+   * Sets the x coordinate.
    * @param x x coordinate
    */
   public void setX(final double x) {
     this.x = x;
   }
-  
+
   /**
-   * Returns the y coordinate
+   * Returns the y coordinate.
    * @return y coordinate
    */
   public double getY() {
     return y;
   }
-  
+
   /**
-   * Sets the y coordinate
+   * Sets the y coordinate.
    * @param y y coordinate
    */
   public void setY(final double y) {
@@ -89,15 +84,15 @@ public class Point extends Geospatial {
   }
 
   /**
-   * Returns the z coordinate
+   * Returns the z coordinate.
    * @return z coordinate
    */
   public double getZ() {
     return z;
   }
-  
+
   /**
-   * Sets the z coordinate
+   * Sets the z coordinate.
    * @param z z coordinate
    */
   public void setZ(final double z) {
@@ -106,8 +101,43 @@ public class Point extends Geospatial {
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyPoint
-            : EdmPrimitiveTypeKind.GeometryPoint;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyPoint :
+        EdmPrimitiveTypeKind.GeometryPoint;
+  }
+
+  @Override
+  public boolean equals(final Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    final Point point = (Point) o;
+    return dimension == point.dimension
+        && (srid == null ? point.srid == null : srid.equals(point.srid))
+        && x == point.x
+        && y == point.y
+        && z == point.z;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = dimension == null ? 0 : dimension.hashCode();
+    result = 31 * result + (srid == null ? 0 : srid.hashCode());
+    result = 31 * result + Double.valueOf(x).hashCode();
+    result = 31 * result + Double.valueOf(y).hashCode();
+    result = 31 * result + Double.valueOf(z).hashCode();
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    return (dimension == null ? "" : dimension.name())
+        + '\''
+        + (srid == null ? "" : "SRID=" + srid.toString() + ';')
+        + "Point(" + x + ' ' + y + ")'";
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
index c59d73f..7ac4681 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
@@ -27,14 +27,11 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
  */
 public class Polygon extends Geospatial {
 
-  private static final long serialVersionUID = 7797602503445391678L;
-
   final ComposedGeospatial<Point> interior;
-
   final ComposedGeospatial<Point> exterior;
-  
+
   /**
-   * Creates a new polygon
+   * Creates a new polygon.
    * 
    * @param dimension   Dimension of the polygon
    * @param srid        SRID values
@@ -69,8 +66,33 @@ public class Polygon extends Geospatial {
 
   @Override
   public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
-    return dimension == Dimension.GEOGRAPHY
-        ? EdmPrimitiveTypeKind.GeographyPolygon
-            : EdmPrimitiveTypeKind.GeometryPolygon;
+    return dimension == Dimension.GEOGRAPHY ?
+        EdmPrimitiveTypeKind.GeographyPolygon :
+        EdmPrimitiveTypeKind.GeometryPolygon;
+  }
+
+  @Override
+  public boolean equals(final Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    final Polygon polygon = (Polygon) o;
+    return dimension == polygon.dimension
+        && (srid == null ? polygon.srid == null : srid.equals(polygon.srid))
+        && (interior == null ? polygon.interior == null : interior.equals(polygon.interior))
+        && (exterior == null ? polygon.exterior == null : exterior.equals(polygon.exterior));
+  }
+
+  @Override
+  public int hashCode() {
+    int result = dimension == null ? 0 : dimension.hashCode();
+    result = 31 * result + (srid == null ? 0 : srid.hashCode());
+    result = 31 * result + (interior == null ? 0 : interior.hashCode());
+    result = 31 * result + (exterior == null ? 0 : exterior.hashCode());
+    return result;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26f7d2a6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java
index 1b1a1b0..0f28772 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java
@@ -18,10 +18,10 @@
  */
 package org.apache.olingo.commons.api.edm.geo;
 
-import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
-
 import java.io.Serializable;
 
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+
 /**
  * A geometry or geography property MAY define a value for the SRID attribute. The value
of this attribute identifies
  * which spatial reference system is applied to values of the property on type instances.
@@ -29,23 +29,22 @@ import java.io.Serializable;
  * The value of the SRID attribute MUST be a non-negative integer or the special value <tt>variable</tt>.
If no value is
  * specified, the attribute defaults to 0 for Geometry types or 4326 for Geography types.
  * <br/>
- * Standards Track Work Product Copyright © OASIS Open 2013. All Rights Reserved. 19 November
2013 Page 22 of 83The
- * valid values of the SRID attribute and their meanings are as defined by the European Petroleum
Survey Group [EPSG].
+ * Standards Track Work Product Copyright © OASIS Open 2013. All Rights Reserved. 19 November
2013
+ * <br>
+ * The valid values of the SRID attribute and their meanings are as defined by the
+ * European Petroleum Survey Group [EPSG].
  */
 public final class SRID implements Serializable {
 
-  private static final String VARIABLE = "variable";
-
   private static final long serialVersionUID = 8412685060902464629L;
+  private static final String VARIABLE = "variable";
 
   private Dimension dimension = Dimension.GEOGRAPHY;
-
   private Integer value;
-
   private Boolean variable;
   
   /**
-   * Creates a new SRID instance from a given 
+   * Creates a new SRID instance from a given value.
    * @param exp Either "variable" or a numeric non-negative SRID value
    * @return SRID instance
    */
@@ -70,15 +69,15 @@ public final class SRID implements Serializable {
   }
 
   /**
-   * Returns the dimension of the SRID instance
+   * Returns the dimension of the SRID instance.
    * @return dimension of the SRID instance
    */
   public Dimension getDimension() {
     return dimension;
   }
-  
+
   /**
-   * Sets the dimension of the SRID instance
+   * Sets the dimension of the SRID instance.
    * @param dimension dimension of the SRID instance
    */
   public void setDimension(final Dimension dimension) {
@@ -86,27 +85,13 @@ public final class SRID implements Serializable {
   }
 
   private String getValue() {
-    if (value == null) {
-      if (dimension == Dimension.GEOMETRY) {
-        return "0";
-      } else {
-        return "4326";
-      }
-    }
-
-    return value.toString();
-//    return value == null ? dimension == Dimension.GEOMETRY
-//        ? "0"
-//            : "4326"
-//        : value.getName();
+    return value == null ?
+        dimension == Dimension.GEOMETRY ? "0" : "4326" :
+        value.toString();
   }
 
-  private boolean isVariable() {
-    return variable != null && variable;
-  }
-  
   /**
-   * Returns true if the value of the instance is not equals to the default (uninitialized)
+   * Returns true if the value of the instance is not equals to the default (uninitialized).
    * @return true if the value of the instance is not equals to the default (uninitialized)
    */
   public boolean isNotDefault() {
@@ -144,8 +129,6 @@ public final class SRID implements Serializable {
 
   @Override
   public String toString() {
-    return isVariable()
-        ? VARIABLE
-        : getValue();
+    return variable != null && variable ? VARIABLE : getValue();
   }
 }


Mime
View raw message