1 22 package org.jboss.test.cluster.web.aop.jdk5; 23 24 import java.util.*; 25 26 27 36 @org.jboss.cache.aop.annotation.InstanceOfPojoCacheable 37 public class Person 38 { 39 String name = null; 40 int age = 0; 41 Map hobbies = null; 42 Address address = null; 43 Set skills; 44 List languages; 45 transient String currentStatus = "Active"; 47 List medication = null; 50 static final int AGE1 = 50; 51 static final int AGE2 = 60; 52 53 public Person() { 54 55 } 56 57 public String getName() 58 { 59 return name; 60 } 61 62 public void setName(String name) 63 { 64 this.name = name; 65 } 66 67 public void setCurrentStatus(String status) { 68 currentStatus = status; 69 } 70 71 public String getCurrentStatus() { 72 return currentStatus; 73 } 74 75 public void setName(Object obj) 76 { 77 this.name = (String )obj; 78 } 79 80 public int getAge() 81 { 82 return age; 83 } 84 85 public void setAge(int age) 86 { 87 88 this.age = age; 89 90 if(age < AGE1) { 92 if(medication != null) { 93 medication.clear(); 94 medication=null; 95 } 96 } 97 else { 98 if( age >= AGE1 ) { 99 addMedication("Lipitor"); 100 } 101 102 if (age >= AGE2) { 103 addMedication("Vioxx"); 104 } 105 } 106 107 108 } 109 110 void addMedication(String name) { 111 if( medication == null ) 112 medication = new ArrayList(); 113 if(!medication.contains(name)) 114 medication.add(name); 115 } 116 117 public Map getHobbies() 118 { 119 return hobbies; 120 } 121 122 public void setHobbies(Map hobbies) 123 { 124 this.hobbies = hobbies; 125 } 126 127 public Address getAddress() 128 { 129 return address; 130 } 131 132 public void setAddress(Address address) 133 { 134 this.address = address; 135 } 136 137 public Set getSkills() 138 { 139 return skills; 140 } 141 142 public void setSkills(Set skills) 143 { 144 this.skills = skills; 145 } 146 147 public List getMedication() 148 { 149 return medication; 150 } 151 152 public void setMedication(List medication) 153 { 154 this.medication = medication; 155 } 156 157 public List getLanguages() 158 { 159 return languages; 160 } 161 162 public void setLanguages(List languages) 163 { 164 this.languages = languages; 165 } 166 167 public String toString() 168 { 169 StringBuffer sb=new StringBuffer (); 170 sb.append("name=").append(getName()).append(", age=").append(getAge()).append(", hobbies=") 171 .append(print(getHobbies())).append(", address=").append(getAddress()).append(", skills=") 172 .append(skills).append(", languages=").append(languages).toString(); 173 if(medication != null) 174 sb.append(", medication=" + medication); 175 return sb.toString(); 176 } 177 178 public String print(Map m) 179 { 180 StringBuffer sb = new StringBuffer (); 181 Map.Entry entry; 182 if (m != null) { 183 for (Iterator it = m.entrySet().iterator(); it.hasNext();) { 184 entry = (Map.Entry) it.next(); 185 sb.append(entry.getKey()).append(": ").append(entry.getValue()); 186 sb.append("\n"); 187 } 188 } 189 return sb.toString(); 190 } 191 } 192 | Popular Tags |