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