/** * Gets the default string representation of the parameter object. * * @param obj * @param klass * @return */ public static String toString(final Object obj, final Class<?> klass) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return toString(obj, klass, null); }
/** * Gets the default string representation of the parameter object. * * @param obj * @param klass * @return */ public static String toString(final Object obj, final Class<?> klass) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return toString(obj, klass, null); }
/** * Creates a message with optional var injection. * Message format: "A String with any number of {} placeholders that will have the vars injected in order" * @param message the message string with the injection placeholders ({}) * @param vars the vars to inject into the the message template; some type conversion will occur for common data * types */ public void message(String message, final Object... vars) { if (ArrayUtils.isEmpty(vars)) { pw.println(message); } else { for (final Object var : vars) { try { message = StringUtils.replaceOnce(message, "{}", TypeUtil.toString(var)); } catch (Exception e) { log.error("Could not derive a valid String representation for {} using TypeUtil.toString(..)", var, e); message = StringUtils.replaceOnce(message, "{}", "???"); } } pw.println(message); } }
/** * Creates a message with optional var injection. * Message format: "A String with any number of {} placeholders that will have the vars injected in order" * @param message the message string with the injection placeholders ({}) * @param vars the vars to inject into the the message template; some type conversion will occur for common data * types */ public void message(String message, final Object... vars) { if (ArrayUtils.isEmpty(vars)) { pw.println(message); } else { for (final Object var : vars) { try { message = StringUtils.replaceOnce(message, "{}", TypeUtil.toString(var)); } catch (Exception e) { log.error("Could not derive a valid String representation for {} using TypeUtil.toString(..)", var, e); message = StringUtils.replaceOnce(message, "{}", "???"); } } pw.println(message); } }