ObjectUtil { public static boolean isSameType(Object object1, Object object2) { if ((object1 == null) || (object2 == null)) { return true; } return object1.getClass().equals(object2.getClass()); }  static T defaultIfNull(T object, S defaultValue); static boolean isEquals(Object object1, Object object2); static int hashCode(Object object); static int identityHashCode(Object object); static String identityToString(Object object); static String identityToString(Object object, String nullStr); static A appendIdentityToString(A buffer, Object object); static String toString(Object object); static String toString(Object object, String nullStr); static boolean isSameType(Object object1, Object object2); static boolean isEmpty(Object object); static boolean isNotEmpty(Object object); static boolean isNull(Object object); static boolean isNotNull(Object object); static boolean isAllNull(Object...objects); static boolean isAnyNull(Object...objects); static int nullNum(Object...objects); static StringBuilder appendIdentityToString(StringBuilder builder, Object object); static StringBuffer appendIdentityToString(StringBuffer buffer, Object object); static Object clone(Object array); static final String SERIAL_VERSION_UID; }
@Test public void isSameType() { assertTrue(ObjectUtil.isSameType(null, null)); assertTrue(ObjectUtil.isSameType(null, Boolean.TRUE)); assertTrue(ObjectUtil.isSameType(Boolean.TRUE, null)); assertTrue(ObjectUtil.isSameType(Boolean.TRUE, Boolean.FALSE)); assertFalse(ObjectUtil.isSameType(Boolean.TRUE, new Integer(0))); }