コード例 #1
0
  @Override
  public void visit(final FieldDeclaration declaration, final Map<String, CompilationUnit> arg) {
    super.visit(declaration, arg);

    Comment declarationComment = declaration.getComment();
    if (declarationComment != null) {
      Matcher matcher = ENUM_REGEX.matcher(declarationComment.toString());
      if (matcher.find()) {
        if (declaration.getParentNode() instanceof ClassOrInterfaceDeclaration) {
          ClassOrInterfaceDeclaration clazz =
              (ClassOrInterfaceDeclaration) declaration.getParentNode();

          /* Defines the name of the enumeration generated */
          String name = matcher.group(1) + matcher.group(2) + enumNamePostFix;

          nameValuesMap.putIfAbsent(name, new ArrayList());
          nameValuesMap.get(name).addAll(declaration.getVariables());
          if (!clazz.getName().equals(baseClassName)) {
            nameParentClassMap.put(name, clazz.getName());
          }
        } else {
          throw new Error("Parent of Enum declaration was not a ClassOrInterfaceDeclaration");
        }
      }
    }
  }
コード例 #2
0
 private void visitComment(final Comment n, final A arg) {
   if (n != null) {
     n.accept(this, arg);
   }
 }