jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1304405 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/ScalarImpl.java
Date Fri, 23 Mar 2012 15:05:31 GMT
Author: mduerig
Date: Fri Mar 23 15:05:31 2012
New Revision: 1304405

URL: http://svn.apache.org/viewvc?rev=1304405&view=rev
Log:
OAK-33: Values in oak-core (WIP)
- fix equals

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/ScalarImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/ScalarImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/ScalarImpl.java?rev=1304405&r1=1304404&r2=1304405&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/ScalarImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/ScalarImpl.java Fri
Mar 23 15:05:31 2012
@@ -125,11 +125,12 @@ public abstract class ScalarImpl impleme
             if (this == other) {
                 return true;
             }
-            if (other == null || getClass() != other.getClass()) {
+            if (!(other instanceof Scalar)) {
                 return false;
             }
 
-            return value == ((BooleanScalar) other).value;
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.BOOLEAN && that.getBoolean()
== value;
         }
 
         @Override
@@ -152,7 +153,15 @@ public abstract class ScalarImpl impleme
 
         @Override
         public boolean equals(Object other) {
-            return this == other || other != null && getClass() == other.getClass();
+            if (this == other) {
+                return true;
+            }
+            if (!(other instanceof Scalar)) {
+                return false;
+            }
+
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.NULL;
         }
 
         @Override
@@ -184,11 +193,12 @@ public abstract class ScalarImpl impleme
             if (this == other) {
                 return true;
             }
-            if (other == null || getClass() != other.getClass()) {
+            if (!(other instanceof Scalar)) {
                 return false;
             }
 
-            return value == ((LongScalar) other).value;
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.LONG && that.getLong()
== value;
         }
 
         @Override
@@ -220,12 +230,12 @@ public abstract class ScalarImpl impleme
             if (this == other) {
                 return true;
             }
-            if (other == null || getClass() != other.getClass()) {
+            if (!(other instanceof Scalar)) {
                 return false;
             }
 
-            return Double.compare(((DoubleScalar) other).value, value) == 0;
-
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.DOUBLE && Double.compare(that.getDouble(),
value) == 0;
         }
 
         @Override
@@ -249,15 +259,16 @@ public abstract class ScalarImpl impleme
         }
 
         @Override
-        public boolean equals(Object o) {
-            if (this == o) {
+        public boolean equals(Object other) {
+            if (this == other) {
                 return true;
             }
-            if (o == null || getClass() != o.getClass()) {
+            if (!(other instanceof Scalar)) {
                 return false;
             }
 
-            return value.equals(((StringScalar) o).value);
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.STRING && that.getString().equals(value);
         }
 
         @Override
@@ -284,11 +295,12 @@ public abstract class ScalarImpl impleme
             if (this == other) {
                 return true;
             }
-            if (other == null || getClass() != other.getClass()) {
+            if (!(other instanceof Scalar)) {
                 return false;
             }
 
-            return value.equals(((SmallBinaryScalar) other).value);
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.BINARY && that.getString().equals(value);
         }
 
         @Override
@@ -326,11 +338,12 @@ public abstract class ScalarImpl impleme
             if (this == other) {
                 return true;
             }
-            if (other == null || getClass() != other.getClass()) {
+            if (!(other instanceof Scalar)) {
                 return false;
             }
 
-            return getString().equals(((BinaryScalar) other).getString());
+            Scalar that = (Scalar) other;
+            return that != null && that.getType() == Scalar.BINARY && that.getString().equals(getString());
         }
 
         @Override



Mime
View raw message