@Test public void testequals() throws Exception { assertTrue(ArrayUtil.equals(new long[] { 1 }, new long[] { 1 })); assertTrue(ArrayUtil.equals(new int[] { 1 }, new int[] { 1 })); assertTrue(ArrayUtil.equals(new short[] { 1 }, new short[] { 1 })); assertTrue(ArrayUtil.equals(new char[] { 1 }, new char[] { 1 })); assertTrue(ArrayUtil.equals(new byte[] { 1 }, new byte[] { 1 })); assertTrue(ArrayUtil.equals(new boolean[] { true }, new boolean[] { true })); assertTrue(ArrayUtil.equals(new float[] { 1f }, new float[] { 1f })); assertTrue(ArrayUtil.equals(new double[] { 1d }, new double[] { 1d })); assertTrue(ArrayUtil.equals(new Object[] { "str" }, new Object[] { "str" })); assertFalse(ArrayUtil.equals(new long[] { 1 }, new long[] { 2 })); assertFalse(ArrayUtil.equals(new int[] { 1 }, new int[] { 2 })); assertFalse(ArrayUtil.equals(new short[] { 1 }, new short[] { 2 })); assertFalse(ArrayUtil.equals(new char[] { 1 }, new char[] { 2 })); assertFalse(ArrayUtil.equals(new byte[] { 1 }, new byte[] { 2 })); assertFalse(ArrayUtil.equals(new boolean[] { true }, new boolean[] { false })); assertFalse(ArrayUtil.equals(new float[] { 1f }, new float[] { 2f })); assertFalse(ArrayUtil.equals(new double[] { 1d }, new double[] { 2d })); assertFalse(ArrayUtil.equals(new Object[] { "str" }, new Object[] { "rts" })); assertTrue(ArrayUtil.equals(null, null)); assertFalse(ArrayUtil.equals(new long[] { 1 }, null)); assertFalse(ArrayUtil.equals(null, new long[] { 1 })); assertTrue(ArrayUtil.equals(1, 1)); assertTrue(ArrayUtil.equals("str", "str")); }
public static boolean equals(Object thisObj, Object thatObj) { if (thisObj == null) { return thatObj == null; } else if (thatObj == null) { return false; } final Class<?> clazz = thisObj.getClass(); if (!clazz.equals(thatObj.getClass())) { return false; } if (!clazz.isArray()) { return thisObj.equals(thatObj); } final Class<?> componentType = clazz.getComponentType(); if (long.class.equals(componentType)) { return Arrays.equals((long[]) thisObj, (long[]) thatObj); } else if (int.class.equals(componentType)) { return Arrays.equals((int[]) thisObj, (int[]) thatObj); } else if (short.class.equals(componentType)) { return Arrays.equals((short[]) thisObj, (short[]) thatObj); } else if (char.class.equals(componentType)) { return Arrays.equals((char[]) thisObj, (char[]) thatObj); } else if (byte.class.equals(componentType)) { return Arrays.equals((byte[]) thisObj, (byte[]) thatObj); } else if (boolean.class.equals(componentType)) { return Arrays.equals((boolean[]) thisObj, (boolean[]) thatObj); } else if (float.class.equals(componentType)) { return Arrays.equals((float[]) thisObj, (float[]) thatObj); } else if (double.class.equals(componentType)) { return Arrays.equals((double[]) thisObj, (double[]) thatObj); } else { return Arrays.equals((Object[]) thisObj, (Object[]) thatObj); } }
ArrayUtil { public static boolean equals(Object thisObj, Object thatObj) { if (thisObj == null) { return thatObj == null; } else if (thatObj == null) { return false; } final Class<?> clazz = thisObj.getClass(); if (!clazz.equals(thatObj.getClass())) { return false; } if (!clazz.isArray()) { return thisObj.equals(thatObj); } final Class<?> componentType = clazz.getComponentType(); if (long.class.equals(componentType)) { return Arrays.equals((long[]) thisObj, (long[]) thatObj); } else if (int.class.equals(componentType)) { return Arrays.equals((int[]) thisObj, (int[]) thatObj); } else if (short.class.equals(componentType)) { return Arrays.equals((short[]) thisObj, (short[]) thatObj); } else if (char.class.equals(componentType)) { return Arrays.equals((char[]) thisObj, (char[]) thatObj); } else if (byte.class.equals(componentType)) { return Arrays.equals((byte[]) thisObj, (byte[]) thatObj); } else if (boolean.class.equals(componentType)) { return Arrays.equals((boolean[]) thisObj, (boolean[]) thatObj); } else if (float.class.equals(componentType)) { return Arrays.equals((float[]) thisObj, (float[]) thatObj); } else if (double.class.equals(componentType)) { return Arrays.equals((double[]) thisObj, (double[]) thatObj); } else { return Arrays.equals((Object[]) thisObj, (Object[]) thatObj); } } }
ArrayUtil { public static boolean equals(Object thisObj, Object thatObj) { if (thisObj == null) { return thatObj == null; } else if (thatObj == null) { return false; } final Class<?> clazz = thisObj.getClass(); if (!clazz.equals(thatObj.getClass())) { return false; } if (!clazz.isArray()) { return thisObj.equals(thatObj); } final Class<?> componentType = clazz.getComponentType(); if (long.class.equals(componentType)) { return Arrays.equals((long[]) thisObj, (long[]) thatObj); } else if (int.class.equals(componentType)) { return Arrays.equals((int[]) thisObj, (int[]) thatObj); } else if (short.class.equals(componentType)) { return Arrays.equals((short[]) thisObj, (short[]) thatObj); } else if (char.class.equals(componentType)) { return Arrays.equals((char[]) thisObj, (char[]) thatObj); } else if (byte.class.equals(componentType)) { return Arrays.equals((byte[]) thisObj, (byte[]) thatObj); } else if (boolean.class.equals(componentType)) { return Arrays.equals((boolean[]) thisObj, (boolean[]) thatObj); } else if (float.class.equals(componentType)) { return Arrays.equals((float[]) thisObj, (float[]) thatObj); } else if (double.class.equals(componentType)) { return Arrays.equals((double[]) thisObj, (double[]) thatObj); } else { return Arrays.equals((Object[]) thisObj, (Object[]) thatObj); } }  }
ArrayUtil { public static boolean equals(Object thisObj, Object thatObj) { if (thisObj == null) { return thatObj == null; } else if (thatObj == null) { return false; } final Class<?> clazz = thisObj.getClass(); if (!clazz.equals(thatObj.getClass())) { return false; } if (!clazz.isArray()) { return thisObj.equals(thatObj); } final Class<?> componentType = clazz.getComponentType(); if (long.class.equals(componentType)) { return Arrays.equals((long[]) thisObj, (long[]) thatObj); } else if (int.class.equals(componentType)) { return Arrays.equals((int[]) thisObj, (int[]) thatObj); } else if (short.class.equals(componentType)) { return Arrays.equals((short[]) thisObj, (short[]) thatObj); } else if (char.class.equals(componentType)) { return Arrays.equals((char[]) thisObj, (char[]) thatObj); } else if (byte.class.equals(componentType)) { return Arrays.equals((byte[]) thisObj, (byte[]) thatObj); } else if (boolean.class.equals(componentType)) { return Arrays.equals((boolean[]) thisObj, (boolean[]) thatObj); } else if (float.class.equals(componentType)) { return Arrays.equals((float[]) thisObj, (float[]) thatObj); } else if (double.class.equals(componentType)) { return Arrays.equals((double[]) thisObj, (double[]) thatObj); } else { return Arrays.equals((Object[]) thisObj, (Object[]) thatObj); } }  static int hashCode(Object obj); static boolean equals(Object thisObj, Object thatObj); static String toString(Object obj); }
ArrayUtil { public static boolean equals(Object thisObj, Object thatObj) { if (thisObj == null) { return thatObj == null; } else if (thatObj == null) { return false; } final Class<?> clazz = thisObj.getClass(); if (!clazz.equals(thatObj.getClass())) { return false; } if (!clazz.isArray()) { return thisObj.equals(thatObj); } final Class<?> componentType = clazz.getComponentType(); if (long.class.equals(componentType)) { return Arrays.equals((long[]) thisObj, (long[]) thatObj); } else if (int.class.equals(componentType)) { return Arrays.equals((int[]) thisObj, (int[]) thatObj); } else if (short.class.equals(componentType)) { return Arrays.equals((short[]) thisObj, (short[]) thatObj); } else if (char.class.equals(componentType)) { return Arrays.equals((char[]) thisObj, (char[]) thatObj); } else if (byte.class.equals(componentType)) { return Arrays.equals((byte[]) thisObj, (byte[]) thatObj); } else if (boolean.class.equals(componentType)) { return Arrays.equals((boolean[]) thisObj, (boolean[]) thatObj); } else if (float.class.equals(componentType)) { return Arrays.equals((float[]) thisObj, (float[]) thatObj); } else if (double.class.equals(componentType)) { return Arrays.equals((double[]) thisObj, (double[]) thatObj); } else { return Arrays.equals((Object[]) thisObj, (Object[]) thatObj); } }  static int hashCode(Object obj); static boolean equals(Object thisObj, Object thatObj); static String toString(Object obj);  }