mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
add Arrays test for equals and hashCode, handle corner cases with null
This commit is contained in:
@ -43,15 +43,25 @@ public class Arrays {
|
||||
}
|
||||
|
||||
public static int hashCode(Object[] array) {
|
||||
if(array == null) {
|
||||
return 9023;
|
||||
}
|
||||
|
||||
int hc = 823347;
|
||||
for(Object o : array) {
|
||||
hc += o.hashCode();
|
||||
hc += o != null ? o.hashCode() : 54267;
|
||||
hc *= 3;
|
||||
}
|
||||
return hc;
|
||||
}
|
||||
|
||||
public static boolean equals(Object[] a, Object[] b) {
|
||||
if(a == b) {
|
||||
return true;
|
||||
}
|
||||
if(a == null || b == null) {
|
||||
return false;
|
||||
}
|
||||
if(a.length != b.length) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user