@@ -128,28 +128,18 @@ private static class Hash<T> {
128128 * @return the computed hash value
129129 */
130130 public int compute (T key ) {
131- String keyString ;
132- if (key instanceof Object [] objectArray ) {
133- keyString = Arrays .deepToString (objectArray );
134- } else if (key instanceof int [] intArray ) {
135- keyString = Arrays .toString (intArray );
136- } else if (key instanceof long [] longArray ) {
137- keyString = Arrays .toString (longArray );
138- } else if (key instanceof double [] doubleArray ) {
139- keyString = Arrays .toString (doubleArray );
140- } else if (key instanceof float [] floatArray ) {
141- keyString = Arrays .toString (floatArray );
142- } else if (key instanceof boolean [] booleanArray ) {
143- keyString = Arrays .toString (booleanArray );
144- } else if (key instanceof byte [] byteArray ) {
145- keyString = Arrays .toString (byteArray );
146- } else if (key instanceof char [] charArray ) {
147- keyString = Arrays .toString (charArray );
148- } else if (key instanceof short [] shortArray ) {
149- keyString = Arrays .toString (shortArray );
150- } else {
151- keyString = String .valueOf (key );
152- }
131+ String keyString = switch (key ) {
132+ case Object [] arr -> Arrays .deepToString (arr );
133+ case int [] arr -> Arrays .toString (arr );
134+ case long [] arr -> Arrays .toString (arr );
135+ case double [] arr -> Arrays .toString (arr );
136+ case float [] arr -> Arrays .toString (arr );
137+ case boolean [] arr -> Arrays .toString (arr );
138+ case byte [] arr -> Arrays .toString (arr );
139+ case char [] arr -> Arrays .toString (arr );
140+ case short [] arr -> Arrays .toString (arr );
141+ case null , default -> String .valueOf (key );
142+ };
153143 return index * asciiString (keyString );
154144 }
155145
0 commit comments