/** * Check if this method is a mutator or accessor method for a field. * <p/> * If method starts with set or get and is longer than 3 characters. * For example java.util.List.set(int index, Object element) is considered to be a method, not a setter. * * @param m */ private boolean isNotGetterOrSetter(final Method m) { return !(isSetter(m) || isGetter(m) || isBooleanGetter(m)); }
public ClassMethodInspector(final Class<?> clazz, final ClassToGenericClassConverter converter) throws IOException { final Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method aMethod = methods[i]; int modifiers = methods[i].getModifiers(); String methodName = aMethod.getName(); if (isNotGetterOrSetter(aMethod) && !BlackLists.isClassMethodBlackListed(clazz, methodName) && Modifier.isPublic(modifiers)) { Class<?>[] listParam = aMethod.getParameterTypes(); MethodInfo info = new MethodInfo(methodName, convertParameterTypes(converter, listParam), aMethod.getReturnType(), obtainGenericType(aMethod.getGenericReturnType()), converter.translateClassToGenericType(aMethod.getReturnType())); this.methods.add(info); } } }
ClassMethodInspector methodInspector = new ClassMethodInspector(clazz, typeSystemConverter); final List<MethodInfo> methodInformation = methodInspector.getMethodInfos(); for (final MethodInfo mi : methodInformation) { final String genericType = mi.getParametricReturnType();