1 25 26 package org.objectweb.speedo.pobjects.fetchgroup; 27 28 import java.util.Iterator ; 29 import java.util.Set ; 30 31 34 public class Person { 35 36 private String name; 37 private Address address; 38 private Set children; 39 private int age; 40 41 public Person() { 42 } 43 44 public Person(String name, Address address, Set children, int age){ 45 this.name = name; 46 this.address = address; 47 this.children = children; 48 this.age = age; 49 } 50 51 public Address getAddress() { 52 return address; 53 } 54 55 public void setAddress(Address address) { 56 this.address = address; 57 } 58 59 public Set getChildren() { 60 return children; 61 } 62 63 public void setChildren(Set children) { 64 this.children = children; 65 } 66 67 public boolean hasChildren(){ 68 if(children == null) 69 return false; 70 return !children.isEmpty(); 71 } 72 73 public String getName() { 74 return name; 75 } 76 77 public void setName(String name) { 78 this.name = name; 79 } 80 81 public int getAge() { 82 return age; 83 } 84 85 public void setAge(int age) { 86 this.age = age; 87 } 88 89 public String toString(){ 90 String s = "Person[" + name + ", " + age; 91 if(address != null) 92 s += ", " + address.toString(); 93 else 94 s += ", no address"; 95 if(hasChildren()){ 96 s += "\n"; 97 Iterator it = children.iterator(); 98 while(it.hasNext()){ 99 Person p = (Person) it.next(); 100 s += "\t" + p.toString() + "\n"; 101 } 102 } 103 else{ 104 s += ", no child"; 105 } 106 s += "]"; 107 return s; 108 } 109 } 110 | Popular Tags |