Skip to content
Permalink
Browse files
Improved: Remove useless ‘UtilObject#compareToHelper’
(OFBIZ-11140)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863445 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jul 19, 2019
1 parent 1427c57 commit 7b0053b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
@@ -96,20 +96,6 @@ public static Object getObjectException(byte[] bytes) throws ClassNotFoundExcept
}
}

public static <T> int compareToHelper(Comparable<T> o1, T o2) {
if (o1 == o2) {
// handles same-reference, or null
return 0;
} else if (o1 == null) {
return -1;
} else if (o2 == null) {
// either o1 or o2 is null, but not both
return 1;
} else {
return o1.compareTo(o2);
}
}

public static int doHashCode(Object o1) {
if (o1 == null) {
return 0;
@@ -235,16 +235,6 @@ public void testGetByteCount() throws Exception {
}
}

public void testCompareToHelper() {
Long one = 1L;
Long two = 2L;
assertComparison("one <-> two", -1, UtilObject.compareToHelper(one, two));
assertComparison("one <-> one", 0, UtilObject.compareToHelper(one, one));
assertComparison("two <-> one", 1, UtilObject.compareToHelper(two, one));
assertComparison("one <-> null", 1, UtilObject.compareToHelper(one, null));
assertComparison("null <-> one", -1, UtilObject.compareToHelper(null, one));
}

public void testDoHashCode() throws Exception {
UtilObject.doHashCode(this);
UtilObject.doHashCode(null);

0 comments on commit 7b0053b

Please sign in to comment.