/** * Checks whether the method name starts with a getter prefix. * * @param method the method to check for * @return true if the method name starts with eiher one of values stored in GETTER_PREFIXES */ public static boolean isGetterMethod(final Method method) { if (method != null) { return isGetterMethod(method.getName()); } else { return false; } }
/** * Checks whether the method name starts with a getter prefix. * * @param method the method to check for * @return true if the method name starts with eiher one of values stored in GETTER_PREFIXES */ public static boolean isGetterMethod(final Method method) { if (method != null) { return isGetterMethod(method.getName()); } else { return false; } }
if (isGetterMethod(method.getName())) { fieldName = getFieldName(method.getName());
/** * Strips getter prefix from method name. * * @param methodName the name of the method to be processed * @return the stripped method name with Decapitalized first letter or null if passed method name has no getter prefix. */ public static String getFieldName(final String methodName) { if (isGetterMethod(methodName)) { return decapitalizeFirstCharOfString(stripGetterPrefix(methodName)); } return null; }
/** * Gets the full qualified name of a field or non getter method. * Result has following format : "Full Qualified Classname"."field name for getter methods or method name for non getter methods". * * @param method The method to be processed * @return */ public static String getFullQualifiedFieldName(final Class type, final Method method) { if (method != null) { // get the name of the type from passed type or method final String typeName; if (type != null) { typeName = type.getCanonicalName(); } else { typeName = method.getDeclaringClass().getCanonicalName(); } // get field name from getter method or method name for non getter methods final String fieldName; if (isGetterMethod(method.getName())) { fieldName = getFieldName(method.getName()); } else { fieldName = method.getName(); } return typeName + "." + fieldName; } else { return null; } }
/** * Strips getter prefix from method name. * * @param methodName the name of the method to be processed * @return the stripped method name with Decapitalized first letter or null if passed method name has no getter prefix. */ public static String getFieldName(final String methodName) { if (isGetterMethod(methodName)) { return decapitalizeFirstCharOfString(stripGetterPrefix(methodName)); } return null; }