1 46 package org.codehaus.groovy.ast; 47 48 import org.codehaus.groovy.ast.expr.Expression; 49 50 import java.util.ArrayList ; 51 import java.util.HashMap ; 52 import java.util.List ; 53 import java.util.Map ; 54 55 56 62 public class AnnotationNode extends ASTNode { 63 private String name; 64 private Map members = new HashMap (); 65 66 public AnnotationNode(String name) { 67 this.name = name; 68 } 69 70 public String getName() { 71 return name; 72 } 73 74 public Map getMembers() { 75 return members; 76 } 77 78 public Expression getMember(String name) { 79 return (Expression) members.get(name); 80 } 81 82 public void addMember(String name, Expression value) { 83 Expression oldValue = (Expression) members.get(name); 84 if (oldValue == null) { 85 members.put(name, value); 86 } 87 else { 88 List list = null; 89 if (oldValue instanceof List ) { 90 list = (List ) oldValue; 91 } 92 else { 93 list = new ArrayList (); 94 list.add(oldValue); 95 members.put(name, list); 96 } 97 list.add(value); 98 } 99 } 100 101 public void setMember(String name, Expression value) { 102 members.put(name, value); 103 } 104 105 } 106 | Popular Tags |