コード例 #1
0
 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() + "> ";
 }
コード例 #2
0
 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);
       }
     }
   }
 }
コード例 #3
0
 public void visitProperty(PropertyNode node) {
   checkDuplicateProperties(node);
   checkGenericsUsage(node, node.getType());
   super.visitProperty(node);
 }