1 7 package org.jboss.cache.pojo.test; 8 9 import java.util.ArrayList ; 10 import java.util.Iterator ; 11 import java.util.List ; 12 import java.util.Map ; 13 import java.util.Set ; 14 15 16 26 @org.jboss.cache.pojo.annotation.Replicable 28 public class Person 29 { 30 String name = null; 31 int age = 0; 32 Map <String , String > hobbies = null; 33 Address address = null; 34 Set <String > skills; 35 List <String > languages; 36 transient String currentStatus = "Active"; 38 List <String > medication = null; 41 static final int AGE1 = 50; 42 static final int AGE2 = 60; 43 44 public Person() 45 { 46 47 } 48 49 public String getName() 50 { 51 return name; 52 } 53 54 public void setName(String name) 55 { 56 this.name = name; 57 } 58 59 public void setCurrentStatus(String status) 60 { 61 currentStatus = status; 62 } 63 64 public String getCurrentStatus() 65 { 66 return currentStatus; 67 } 68 69 public void setName(Object obj) 70 { 71 this.name = (String ) obj; 72 } 73 74 public int getAge() 75 { 76 return age; 77 } 78 79 public void setAge(int age) 80 { 81 82 this.age = age; 83 84 if (age < AGE1) 86 { 87 if (medication != null) 88 { 89 medication.clear(); 90 medication = null; 91 } 92 } else 93 { 94 if (age >= AGE1) 95 { 96 addMedication("Lipitor"); 97 } 98 99 if (age >= AGE2) 100 { 101 addMedication("Vioxx"); 102 } 103 } 104 105 106 } 107 108 void addMedication(String name) 109 { 110 if (medication == null) 111 medication = new ArrayList (); 112 if (!medication.contains(name)) 113 medication.add(name); 114 } 115 116 public Map <String , String > 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 <String > getSkills() 137 { 138 return skills; 139 } 140 141 public void setSkills(Set skills) 142 { 143 this.skills = skills; 144 } 145 146 public List <String > getMedication() 147 { 148 return medication; 149 } 150 151 public void setMedication(List medication) 152 { 153 this.medication = medication; 154 } 155 156 public List <String > 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 { 183 for (Iterator it = m.entrySet().iterator(); it.hasNext();) 184 { 185 entry = (Map.Entry ) it.next(); 186 sb.append(entry.getKey()).append(": ").append(entry.getValue()); 187 sb.append("\n"); 188 } 189 } 190 return sb.toString(); 191 } 192 } 193 | Popular Tags |