Returns a hash code based on the "deep contents" of the given array. If the array contains other arrays as its elements, the hash code is based on their contents not their identities. So it is not acceptable to invoke this method on an array that contains itself as an element, either directly or ind
(Object[] array)
| 1095 | * @return the hash code for {@code array}. |
| 1096 | */ |
| 1097 | public static int deepHashCode(Object[] array) { |
| 1098 | if (array == null) { |
| 1099 | return 0; |
| 1100 | } |
| 1101 | int hashCode = 1; |
| 1102 | for (Object element : array) { |
| 1103 | int elementHashCode = deepHashCodeElement(element); |
| 1104 | hashCode = 31 * hashCode + elementHashCode; |
| 1105 | } |
| 1106 | return hashCode; |
| 1107 | } |
| 1108 | |
| 1109 | private static int deepHashCodeElement(Object element) { |
| 1110 | Class<?> cl; |
no test coverage detected