Title: [1070] trunk/qdox/src/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java: use pure visitor pattern
Revision
1070
Author
rfscholte
Date
2011-02-22 07:05:45 -0600 (Tue, 22 Feb 2011)

Log Message

use pure visitor pattern 

Modified Paths


Diff

Modified: trunk/qdox/src/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java (1069 => 1070)

--- trunk/qdox/src/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java	2011-02-22 11:02:15 UTC (rev 1069)
+++ trunk/qdox/src/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java	2011-02-22 13:05:45 UTC (rev 1070)
@@ -74,38 +74,15 @@
 	 * @see com.thoughtworks.qdox.builder.AnnotationTransformer#transform(com.thoughtworks.qdox.parser.structs.AnnoDef)
 	 */
 	public Annotation transform(AnnoDef annoDef) {
-		return  createAnnotation(annoDef);
-	}
-
-    private Annotation createAnnotation(AnnoDef annoDef) {
     	Annotation annotation = new Annotation(createType(annoDef.typeDef, 0), annoDef.lineNumber);
     	for(Map.Entry<String, ElemValueDef> annoVal : annoDef.args.entrySet()) {
-    		annotation.setProperty(annoVal.getKey(), createAnnotation(annoVal.getValue()));
+    		annotation.setProperty(annoVal.getKey(), annoVal.getValue().transform(this));
     	}
     	annotation.setContext(parent);
     	return annotation;
-    }
-    
-    private AnnotationValue createAnnotation(ElemValueDef oldValue) {
-		AnnotationValue newValue;
-		if(oldValue instanceof AnnoDef) {
-			newValue = createAnnotation((AnnoDef) oldValue);
-		}
-		else if(oldValue instanceof ElemValueListDef) {
-			ElemValueListDef annoValList = (ElemValueListDef) oldValue;
-			List<AnnotationValue> parsedList = new LinkedList<AnnotationValue>();
-			for(ElemValueDef val : annoValList.valueList) {
-				parsedList.add(createAnnotation(val));
-			}
-			newValue = new AnnotationValueList(parsedList);
-		}
-		else {
-			newValue = oldValue.transform(this);
-		}
-    	return newValue;
-    }
+	}
 
-    public Type createType(TypeDef typeDef, int dimensions) {
+    private Type createType(TypeDef typeDef, int dimensions) {
     	if(typeDef == null) {
     		return null;
     	}
@@ -115,7 +92,7 @@
     public AnnotationValue transform(ElemValueListDef elemValueListDef) {
     	List<AnnotationValue> parsedList = new LinkedList<AnnotationValue>();
 		for(ElemValueDef val : elemValueListDef.valueList) {
-			parsedList.add(createAnnotation(val));
+			parsedList.add(val.transform(this));
 		}
 		return new AnnotationValueList(parsedList);
     }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to