1 25 26 package org.objectweb.speedo.tutorial.pobjects.mapping; 27 28 import java.util.ArrayList ; 29 import java.util.Collection ; 30 import java.util.Iterator ; 31 32 35 public class Manager { 36 37 private String name; 38 private Department department; 40 private Collection employees; 42 43 public Manager(String name){ 44 this.name = name; 45 department = null; 46 employees = new ArrayList (); 47 } 48 49 public Manager(String name, Department department){ 50 this.name = name; 51 this.department = department; 52 employees = new ArrayList (); 53 } 54 55 public Department getDepartment() { 56 return department; 57 } 58 public void setDepartment(Department department) { 59 this.department = department; 60 } 61 62 public Collection getEmployees() { 63 return employees; 64 } 65 public void setEmployees(Collection employees) { 66 this.employees = employees; 67 } 68 public void addEmployee(Employee employee){ 69 employees.add(employee); 70 } 71 72 public String getName() { 73 return name; 74 } 75 public void setName(String name) { 76 this.name = name; 77 } 78 79 public String toString(){ 80 String s = "Name: " + name + ", Head-Of: " + department.getLabel() + ", Employees:["; 81 Iterator it = employees.iterator(); 82 while(it.hasNext()){ 83 Employee e = (Employee) it.next(); 84 s += e.getName() + ", "; 85 } 86 s = s.substring(0, s.length()-2); 87 s += "]"; 88 return s; 89 } 90 } 91 | Popular Tags |