### Question:
ClassUtil { public static String getPropertyName(final Method method) { Assertion.check() .isNotNull(method); final String property; if (method.getName().startsWith("get")) { property = method.getName().substring("get".length()); } else if (method.getName().startsWith("is")) { Assertion.check() .isTrue(Boolean.class.equals(method.getReturnType()) || boolean.class.equals(method.getReturnType()), "une méthode is concerne un boolean : {0}", method); property = method.getName().substring("is".length()); } else { throw new IllegalArgumentException("Type de Méthode " + method + " non gérée en tant que propriété"); } return StringUtil.first2LowerCase(property); } private  ClassUtil(); static Object newInstance(final String javaClassName); static J newInstance(final String javaClassName, final Class<J> type); static J newInstance(final Class<J> clazz); static J newInstance(final Constructor<J> constructor, final Object[] args); static Constructor<J> findConstructor(final Class<J> clazz, final Class<?>[] parameterTypes); static Class<?> classForName(final String javaClassName); static Class<? extends J> classForName(final String javaClassName, final Class<J> type); static Object invoke(final Object instance, final Method method, final Object... args); static void set(final Object instance, final Field field, final Object value); static Object get(final Object instance, final Field field); static Method findMethod(final Class<?> clazz, final String methodName, final Class<?>... parameterTypes); static Collection<Field> getAllFields(final Class<?> clazz, final Class<? extends Annotation> annotation); static Collection<Method> getAllMethods(final Class<?> clazz, final Class<? extends Annotation> annotation); static Collection<Field> getAllFields(final Class<?> clazz); static Collection<Method> getAllMethods(final Class<?> clazz); static Set<Class<?>> getAllInterfaces(final Class<?> clazz); static Class<?> getGeneric(final Constructor<?> constructor, final int i); static Class<?> getGeneric(final Method method, final int i); static Class<?> getGeneric(final Field field); static Class<?> getGeneric(
			final Type type,
			final Supplier<RuntimeException> exceptionSupplier); static String getPropertyName(final Method method);  }### Answer:
@Test public void testGetPropertyName() throws NoSuchMethodException, SecurityException { Method method; method = MyPojo.class.getDeclaredMethod("getValue1"); assertEquals("value1", ClassUtil.getPropertyName(method)); method = MyPojo.class.getDeclaredMethod("getValueCamelCase"); assertEquals("valueCamelCase", ClassUtil.getPropertyName(method)); method = MyPojo.class.getDeclaredMethod("isValue2"); assertEquals("value2", ClassUtil.getPropertyName(method)); }
@Test public void testGetPropertyNameSetterWithError() throws NoSuchMethodException, SecurityException { final Method method = MyPojo.class.getDeclaredMethod("setValue1", Long.class); assertThrows(Exception.class, () -> { final String name = ClassUtil.getPropertyName(method); nop(name); }); }
@Test public void testGetPropertyNameIsWithError() throws NoSuchMethodException, SecurityException { final Method method = MyPojo.class.getDeclaredMethod("isValueLong"); assertThrows(Exception.class, () -> { final String name = ClassUtil.getPropertyName(method); nop(name); }); }
@Test public void testGetPropertyNameHasWithError() throws SecurityException { assertThrows(Exception.class, () -> { final Method method = MyPojo.class.getDeclaredMethod("hasValue2"); final String name = ClassUtil.getPropertyName(method); nop(name); }); }