private MethodDoc setterForField(MethodDoc[] methods, MethodDoc propertyMethod) { final String propertyMethodName = propertyMethod.name(); final String fieldName = propertyMethodName.substring(0, propertyMethodName.lastIndexOf("Property")); final String fieldNameUppercased = "" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); final String setter = "set" + fieldNameUppercased; for (MethodDoc methodDoc : methods) { if (setter.equals(methodDoc.name())) { if (1 == methodDoc.parameters().length && "void".equals(methodDoc.returnType().simpleTypeName()) && (methodDoc.isPublic() || methodDoc.isProtected())) { return methodDoc; } } } return null; }
private MethodDoc getterForField(MethodDoc[] methods, MethodDoc propertyMethod) { final String propertyMethodName = propertyMethod.name(); final String fieldName = propertyMethodName.substring(0, propertyMethodName.lastIndexOf("Property")); final String fieldNameUppercased = "" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); final String getterNamePattern; final String fieldTypeName = propertyMethod.returnType().toString(); if ("boolean".equals(fieldTypeName) || fieldTypeName.endsWith("BooleanProperty")) { getterNamePattern = "(is|get)" + fieldNameUppercased; } else { getterNamePattern = "get" + fieldNameUppercased; } for (MethodDoc methodDoc : methods) { if (Pattern.matches(getterNamePattern, methodDoc.name())) { if (0 == methodDoc.parameters().length && (methodDoc.isPublic() || methodDoc.isProtected())) { return methodDoc; } } } return null; }
result.setVisibility( VisibilityKindEnum.VK_PRIVATE ); } else if ( doc.isProtected() ) { result.setVisibility( VisibilityKindEnum.VK_PROTECTED );