private String getRefDescriptor(ASTNode ref) { if (ref instanceof FieldNode) { FieldNode f = (FieldNode) ref; return "the field " + f.getName() + " "; } else if (ref instanceof PropertyNode) { PropertyNode p = (PropertyNode) ref; return "the property " + p.getName() + " "; } else if (ref instanceof ConstructorNode) { return "the constructor " + ref.getText() + " "; } else if (ref instanceof MethodNode) { return "the method " + ref.getText() + " "; } else if (ref instanceof ClassNode) { return "the super class " + ref + " "; } return "<unknown with class " + ref.getClass() + "> "; }
private void checkDuplicateProperties(PropertyNode node) { ClassNode cn = node.getDeclaringClass(); String name = node.getName(); String getterName = "get" + MetaClassHelper.capitalize(name); if (Character.isUpperCase(name.charAt(0))) { for (PropertyNode propNode : cn.getProperties()) { String otherName = propNode.getField().getName(); String otherGetterName = "get" + MetaClassHelper.capitalize(otherName); if (node != propNode && getterName.equals(otherGetterName)) { String msg = "The field " + name + " and " + otherName + " on the class " + cn.getName() + " will result in duplicate JavaBean properties, which is not allowed"; addError(msg, node); } } } }
public void visitProperty(PropertyNode node) { checkDuplicateProperties(node); checkGenericsUsage(node, node.getType()); super.visitProperty(node); }