@Test public void returnSimpleNameOfMethodWithoutArguments() throws SecurityException, NoSuchMethodException { Method m = Object.class.getMethod("toString"); Assert.assertEquals("Object.toString()", Stringnifier.simpleNameFor(m)); }
public static String simpleNameFor(AccessibleObject object) { if (object instanceof Method) { Method method = (Method) object; return method.getDeclaringClass().getSimpleName() + '.' + method.getName() + argumentsToString(method.getParameterTypes()); } if (object instanceof Constructor<?>) { Constructor<?> constructor = (Constructor<?>) object; return constructor.getDeclaringClass().getSimpleName() + argumentsToString(constructor.getParameterTypes()); } throw new IllegalArgumentException("can only strignify constructors and methods"); }
Stringnifier { public static String simpleNameFor(AccessibleObject object) { if (object instanceof Method) { Method method = (Method) object; return method.getDeclaringClass().getSimpleName() + '.' + method.getName() + argumentsToString(method.getParameterTypes()); } if (object instanceof Constructor<?>) { Constructor<?> constructor = (Constructor<?>) object; return constructor.getDeclaringClass().getSimpleName() + argumentsToString(constructor.getParameterTypes()); } throw new IllegalArgumentException("can only strignify constructors and methods"); } }
Stringnifier { public static String simpleNameFor(AccessibleObject object) { if (object instanceof Method) { Method method = (Method) object; return method.getDeclaringClass().getSimpleName() + '.' + method.getName() + argumentsToString(method.getParameterTypes()); } if (object instanceof Constructor<?>) { Constructor<?> constructor = (Constructor<?>) object; return constructor.getDeclaringClass().getSimpleName() + argumentsToString(constructor.getParameterTypes()); } throw new IllegalArgumentException("can only strignify constructors and methods"); } private  Stringnifier(); }
Stringnifier { public static String simpleNameFor(AccessibleObject object) { if (object instanceof Method) { Method method = (Method) object; return method.getDeclaringClass().getSimpleName() + '.' + method.getName() + argumentsToString(method.getParameterTypes()); } if (object instanceof Constructor<?>) { Constructor<?> constructor = (Constructor<?>) object; return constructor.getDeclaringClass().getSimpleName() + argumentsToString(constructor.getParameterTypes()); } throw new IllegalArgumentException("can only strignify constructors and methods"); } private  Stringnifier(); static String simpleNameFor(AccessibleObject object); }
Stringnifier { public static String simpleNameFor(AccessibleObject object) { if (object instanceof Method) { Method method = (Method) object; return method.getDeclaringClass().getSimpleName() + '.' + method.getName() + argumentsToString(method.getParameterTypes()); } if (object instanceof Constructor<?>) { Constructor<?> constructor = (Constructor<?>) object; return constructor.getDeclaringClass().getSimpleName() + argumentsToString(constructor.getParameterTypes()); } throw new IllegalArgumentException("can only strignify constructors and methods"); } private  Stringnifier(); static String simpleNameFor(AccessibleObject object);  }