コード例 #1
0
  public String resolveAnnotationType(Annotation annotation) {
    StringBuffer type = new StringBuffer();
    AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();

    if (annotationDefinition == null) {
      logger.warn("Annotation definition for annotation: " + annotation + " is not defined.");
      return type.toString();
    }

    if (annotationDefinition.isMarker()) {
      return type.toString();
    }

    // finally we can process annotation members.
    Object memberValue;
    int memberCount = 0;
    for (AnnotationMemberDefinition memberDefinition :
        annotationDefinition.getAnnotationMembers()) {
      if ((memberValue = annotation.getValue(memberDefinition.getName())) != null) {
        // a value has been set for this member.
        if (memberCount == 0) type.append("(");
        if (memberCount > 0) type.append(", ");
        type.append(resolveMemberType(memberDefinition, memberValue));
        memberCount++;
      }
    }
    if (memberCount > 0) type.append(")");

    return type.toString();
  }
コード例 #2
0
 @Override
 public Void visitAnnotation(Object parent, AnnotationDefinition annotationDefinition) {
   printLine(
       "@%s", annotationDefinition.getType().getJavaClassName(), annotationDefinition.getValues());
   return null;
 }
コード例 #3
0
ファイル: ClassDefinition.java プロジェクト: Zillode/drools
 public void addAnnotation(AnnotationDefinition annotationDefinition) {
   if (this.annotations == null) {
     this.annotations = new HashMap<String, AnnotationDefinition>();
   }
   this.annotations.put(annotationDefinition.getName(), annotationDefinition);
 }