@Test public void getString() { Object obj = new Object(); String str1 = CommonUtil.getString(obj); Assert.equals(str1, obj.toString(), ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("CommonUtil.getString调用了Object的toString方法"); obj = null; str1 = CommonUtil.getString(obj); Assert.isNull(str1, ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("null对象的toString还是null"); }
public static String getString(final Object obj) { String result = null; if (obj != null) { result = obj instanceof String ? (String) obj : obj.toString(); } return result; }
CommonUtil { public static String getString(final Object obj) { String result = null; if (obj != null) { result = obj instanceof String ? (String) obj : obj.toString(); } return result; } }
CommonUtil { public static String getString(final Object obj) { String result = null; if (obj != null) { result = obj instanceof String ? (String) obj : obj.toString(); } return result; }  }
CommonUtil { public static String getString(final Object obj) { String result = null; if (obj != null) { result = obj instanceof String ? (String) obj : obj.toString(); } return result; }  static String messageFormat(final String message, final Object... params); static String getTransactionID(); static String getRandomCode(); static String getRandomNumber(final int size); static String getRandomChar(final int size); static String getString(final Object obj); static String notNullStr(final String str); static Date getDate(final Long time); static Integer[] splitId(final String idStr, final String splitor); static Long[] splitIdsByLong(final String idStr, final String splitor); static Integer[] splitId(final String idStr); static boolean wildcardMatch(final Collection<String> rules, final String matchValue); static boolean wildcardMatch(final String rule, final String matchValue); static boolean match(final String rule, final String matchValue); static String removeAllSymbol(final String str); static String replaceAllBlank(final String str); static String replaceRedundantBlank(final String str); static boolean isNotEmpty(final T[] paramTypes); static boolean isEmpty(final T[] paramTypes); }
CommonUtil { public static String getString(final Object obj) { String result = null; if (obj != null) { result = obj instanceof String ? (String) obj : obj.toString(); } return result; }  static String messageFormat(final String message, final Object... params); static String getTransactionID(); static String getRandomCode(); static String getRandomNumber(final int size); static String getRandomChar(final int size); static String getString(final Object obj); static String notNullStr(final String str); static Date getDate(final Long time); static Integer[] splitId(final String idStr, final String splitor); static Long[] splitIdsByLong(final String idStr, final String splitor); static Integer[] splitId(final String idStr); static boolean wildcardMatch(final Collection<String> rules, final String matchValue); static boolean wildcardMatch(final String rule, final String matchValue); static boolean match(final String rule, final String matchValue); static String removeAllSymbol(final String str); static String replaceAllBlank(final String str); static String replaceRedundantBlank(final String str); static boolean isNotEmpty(final T[] paramTypes); static boolean isEmpty(final T[] paramTypes);  }