You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2017/06/16 15:01:06 UTC
empire-db git commit: EMPIREDB-257 new overload for
ObjectUtils.compareEqual
Repository: empire-db
Updated Branches:
refs/heads/master c37be6cd3 -> 94c40819b
EMPIREDB-257
new overload for ObjectUtils.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/94c40819
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/94c40819
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/94c40819
Branch: refs/heads/master
Commit: 94c40819b346137fc61c2e9a4e3f3b383d411571
Parents: c37be6c
Author: Rainer Döbele <do...@apache.org>
Authored: Fri Jun 16 17:01:00 2017 +0200
Committer: Rainer Döbele <do...@apache.org>
Committed: Fri Jun 16 17:01:00 2017 +0200
----------------------------------------------------------------------
.../org/apache/empire/commons/ObjectUtils.java | 23 ++++++++++++++++++++
1 file changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/empire-db/blob/94c40819/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 5f29679..0963bc7 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
@@ -130,6 +130,29 @@ public final class ObjectUtils
// Compare Strings
return o1.toString().equals(o2.toString());
}
+
+ /**
+ * Compares two object arrrays for equality
+ *
+ * @param array1 the first array
+ * @param array2 the second array
+ *
+ * @return true if both arrays are equal or false otherwise
+ */
+ public static boolean compareEqual(Object[] array1, Object[] array2)
+ { // Compare Length
+ int len1 = (array1!=null ? array1.length : 0);
+ int len2 = (array2!=null ? array2.length : 0);
+ if (len1!= len2)
+ return false;
+ // Compare Key Values
+ for (int i = 0; i < len1; i++)
+ { // Check String Values
+ if (!ObjectUtils.compareEqual(array1[i], array2[i]))
+ return false;
+ }
+ return true;
+ }
/**
* Checks whether a preferred value is valid and returns an alternative value if not.