@Test public void testClasses() { assertThat(PrettyTypes.format("Class is %s", PrettyTypesTest.class), equalTo("Class is com.tavianator.sangria.core.PrettyTypesTest")); assertThat(PrettyTypes.format("Class is %s", Simple.class), equalTo("Class is com.tavianator.sangria.core.PrettyTypesTest.Simple")); }
public static String format(String message, Object... args) { Object[] prettyArgs = new Object[args.length]; for (int i = 0; i < args.length; ++i) { Object arg = args[i]; Object prettyArg; if (arg instanceof Class) { prettyArg = format((Class<?>)arg); } else if (arg instanceof Key) { prettyArg = format((Key<?>)arg); } else { prettyArg = arg; } prettyArgs[i] = prettyArg; } return String.format(message, prettyArgs); }
PrettyTypes { public static String format(String message, Object... args) { Object[] prettyArgs = new Object[args.length]; for (int i = 0; i < args.length; ++i) { Object arg = args[i]; Object prettyArg; if (arg instanceof Class) { prettyArg = format((Class<?>)arg); } else if (arg instanceof Key) { prettyArg = format((Key<?>)arg); } else { prettyArg = arg; } prettyArgs[i] = prettyArg; } return String.format(message, prettyArgs); } }
PrettyTypes { public static String format(String message, Object... args) { Object[] prettyArgs = new Object[args.length]; for (int i = 0; i < args.length; ++i) { Object arg = args[i]; Object prettyArg; if (arg instanceof Class) { prettyArg = format((Class<?>)arg); } else if (arg instanceof Key) { prettyArg = format((Key<?>)arg); } else { prettyArg = arg; } prettyArgs[i] = prettyArg; } return String.format(message, prettyArgs); } private  PrettyTypes(); }
PrettyTypes { public static String format(String message, Object... args) { Object[] prettyArgs = new Object[args.length]; for (int i = 0; i < args.length; ++i) { Object arg = args[i]; Object prettyArg; if (arg instanceof Class) { prettyArg = format((Class<?>)arg); } else if (arg instanceof Key) { prettyArg = format((Key<?>)arg); } else { prettyArg = arg; } prettyArgs[i] = prettyArg; } return String.format(message, prettyArgs); } private  PrettyTypes(); static String format(String message, Object... args); }
PrettyTypes { public static String format(String message, Object... args) { Object[] prettyArgs = new Object[args.length]; for (int i = 0; i < args.length; ++i) { Object arg = args[i]; Object prettyArg; if (arg instanceof Class) { prettyArg = format((Class<?>)arg); } else if (arg instanceof Key) { prettyArg = format((Key<?>)arg); } else { prettyArg = arg; } prettyArgs[i] = prettyArg; } return String.format(message, prettyArgs); } private  PrettyTypes(); static String format(String message, Object... args);  }