/** * Return a content-based String representation if <code>obj</code> is * not <code>null</code>; otherwise returns an empty String. * <p>Differs from {@link #nullSafeToString(Object)} in that it returns * an empty String rather than "null" for a <code>null</code> value. * * @param obj the object to build a display String for * @return a display String representation of <code>obj</code> * @see #nullSafeToString(Object) */ public static String getDisplayString(Object obj) { if (obj == null) { return EMPTY_STRING; } return nullSafeToString(obj); }
return nullSafeToString((Object[]) obj); return nullSafeToString((boolean[]) obj); return nullSafeToString((byte[]) obj); return nullSafeToString((char[]) obj); return nullSafeToString((double[]) obj); return nullSafeToString((float[]) obj); return nullSafeToString((int[]) obj); return nullSafeToString((long[]) obj); return nullSafeToString((short[]) obj);
/** * Convenience method to return a String array as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * @param arr the array to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String arrayToDelimitedString(Object[] arr, String delim) { if (Objects.isEmpty(arr)) { return ""; } if (arr.length == 1) { return Objects.nullSafeToString(arr[0]); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(delim); } sb.append(arr[i]); } return sb.toString(); }
/** * Return a content-based String representation if <code>obj</code> is * not <code>null</code>; otherwise returns an empty String. * <p>Differs from {@link #nullSafeToString(Object)} in that it returns * an empty String rather than "null" for a <code>null</code> value. * * @param obj the object to build a display String for * @return a display String representation of <code>obj</code> * @see #nullSafeToString(Object) */ public static String getDisplayString(Object obj) { if (obj == null) { return EMPTY_STRING; } return nullSafeToString(obj); }
/** * Return a content-based String representation if <code>obj</code> is * not <code>null</code>; otherwise returns an empty String. * <p>Differs from {@link #nullSafeToString(Object)} in that it returns * an empty String rather than "null" for a <code>null</code> value. * * @param obj the object to build a display String for * @return a display String representation of <code>obj</code> * @see #nullSafeToString(Object) */ public static String getDisplayString(Object obj) { if (obj == null) { return EMPTY_STRING; } return nullSafeToString(obj); }
return nullSafeToString((Object[]) obj); return nullSafeToString((boolean[]) obj); return nullSafeToString((byte[]) obj); return nullSafeToString((char[]) obj); return nullSafeToString((double[]) obj); return nullSafeToString((float[]) obj); return nullSafeToString((int[]) obj); return nullSafeToString((long[]) obj); return nullSafeToString((short[]) obj);
return nullSafeToString((Object[]) obj); return nullSafeToString((boolean[]) obj); return nullSafeToString((byte[]) obj); return nullSafeToString((char[]) obj); return nullSafeToString((double[]) obj); return nullSafeToString((float[]) obj); return nullSafeToString((int[]) obj); return nullSafeToString((long[]) obj); return nullSafeToString((short[]) obj);
/** * Convenience method to return a String array as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * @param arr the array to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String arrayToDelimitedString(Object[] arr, String delim) { if (Objects.isEmpty(arr)) { return ""; } if (arr.length == 1) { return Objects.nullSafeToString(arr[0]); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(delim); } sb.append(arr[i]); } return sb.toString(); }
/** * Convenience method to return a String array as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * @param arr the array to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String arrayToDelimitedString(Object[] arr, String delim) { if (Objects.isEmpty(arr)) { return ""; } if (arr.length == 1) { return Objects.nullSafeToString(arr[0]); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(delim); } sb.append(arr[i]); } return sb.toString(); }