empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject empire-db git commit: EMPIREDB-262 special enum handling in compareEqual
Date Tue, 25 Jul 2017 10:15:24 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master a5cb2785e -> f56a2dc5c


EMPIREDB-262
special enum handling in compareEqual

Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/f56a2dc5
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/f56a2dc5
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/f56a2dc5

Branch: refs/heads/master
Commit: f56a2dc5c2d2e3c6ef33491600a21f91ba06e654
Parents: a5cb278
Author: Rainer Döbele <doebele@apache.org>
Authored: Tue Jul 25 12:15:19 2017 +0200
Committer: Rainer Döbele <doebele@apache.org>
Committed: Tue Jul 25 12:15:19 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/empire/commons/ObjectUtils.java  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/f56a2dc5/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java b/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
index 3707f45..b10066e 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
@@ -127,6 +127,21 @@ public final class ObjectUtils
             double d2 = ((Number)o2).doubleValue(); 
             return (d1==d2);
         }
+        // Enum
+        if (o1.getClass().isEnum())
+        {   // Special enum handling   
+            if (o2 instanceof Number)
+                return ((Enum<?>)o1).ordinal()==((Number)o2).intValue();
+            else
+                return ((Enum<?>)o1).name().equals(o2);
+        }
+        else if (o2.getClass().isEnum())
+        {   // Special enum handling   
+            if (o1 instanceof Number)
+                return ((Enum<?>)o2).ordinal()==((Number)o1).intValue();
+            else
+                return ((Enum<?>)o2).name().equals(o1);
+        }
         // Compare Strings
         return o1.toString().equals(o2.toString());
     }


Mime
View raw message