package com.ragnarok.jparseutil.dataobject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by ragnarok on 15/6/9.
 * representation an Annotation declaration in Java source, currently not concern about the retention and target
 */
public class AnnotationInfo {
    
    private String name;
    private String qualifiedName;
    
    private HashMap<String, String> typeParamsNameMap = new HashMap<>(); // full qualified name
    private HashMap<String, String> paramsDefaultValueMap = new HashMap<>();
    
    public void setSimpleName(String name) {
        this.name = name;
    }
    
    public String getSimpleName() {
        return this.name;
    }
    
    public void setQualifiedName(String qualifiedName) {
        this.qualifiedName = qualifiedName;
    }
    
    public String getQualifiedName() {
        return this.qualifiedName;
    }
    
    // the type must fully qualified
    public void putParams(String type, String name, String defaultValue) {
        this.typeParamsNameMap.put(type, name);
        this.paramsDefaultValueMap.put(name, defaultValue);
    }

    @Override
    public String toString() {
        StringBuilder result = new StringBuilder("Annotation: ");
        result.append(String.format("name: %s, ", name));
        result.append(String.format("qualifiedName: %s", qualifiedName));
        for (Map.Entry<String, String> entry: typeParamsNameMap.entrySet()) {
            result.append(String.format("type: %s, paramName: %s, ", entry.getKey(), entry.getValue()));
        }
        result.append("\n");
        for (Map.Entry<String, String> entry : paramsDefaultValueMap.entrySet()) {
            result.append(String.format("param: %s, defaultValue: %s", entry.getKey(), entry.getValue()));
        }
        return result.toString();
    }
}

@@ -1321,16 +1321,18 @@
 Name: %25s
+, 
 %22, quali
@@ -1339,24 +1339,24 @@
 fiedName));%0A
-
         for 
@@ -1462,17 +1462,22 @@
 format(%22
-t
+paramT
 ype: %25s,
@@ -1496,256 +1496,107 @@
 %25s, 
-%22, entry.getKey(), entry.getValue()));%0A        %7D%0A        result.append(%22%5Cn%22);%0A        for (Map.Entry%3CString, String%3E entry : paramsDefaultValueMap.entrySet()) %7B%0A            result.append(String.format(%22param: %25s, defaultValue: %25s%22, entry.getKey(), 
+defaultValue: %25s%22,%0A                    entry.getKey(), entry.getValue(), paramsDefaultValueMap.get(
 entr
@@ -1609,16 +1609,17 @@
 alue()))
+)
 ;%0A      

fix toString