/** * Strips getter prefix from method name. * * @param method the method to be processed * @return the stripped method name with Decapitalized first letter or null if passed method is null or if the method name has no getter prefix. */ public static String getFieldName(final Method method) { if (method != null) { return getFieldName(method.getName()); } else { return null; } }
/** * Strips getter prefix from method name. * * @param method the method to be processed * @return the stripped method name with Decapitalized first letter or null if passed method is null or if the method name has no getter prefix. */ public static String getFieldName(final Method method) { if (method != null) { return getFieldName(method.getName()); } else { return null; } }
/** * Helper method for getting a corresponsing field for a method * * @param type the type to search the field in * @param method the getter method to search the field for * @return the Field or null if the field for the passed method doesn't exists */ Field getCorrespondingField(Class type, Method method) { try { return type.getDeclaredField(GetterUtilities.getFieldName(method)); } catch (NoSuchFieldException e) { return null; } }
protected void writeToPropertyFile(Profile profile, TypeElement parentElement, Element element, boolean value) throws IOException { FileObjectWrapper fileObject = getOrCreateProfileProperties(filer, profile.getFilename()); String fieldName = GetterUtilities.getFieldName(element.getSimpleName().toString()); if (fieldName == null) { fieldName = element.getSimpleName().toString(); } fileObject.append(((TypeElement) parentElement).getQualifiedName() + "." + fieldName + "=" + value + "\n"); }
/** * 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; } }
fieldName = getFieldName(method.getName());