KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > samples > petclinic > Vet


1 package org.springframework.samples.petclinic;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Collections JavaDoc;
5 import java.util.HashSet JavaDoc;
6 import java.util.List JavaDoc;
7 import java.util.Set JavaDoc;
8 import java.io.Serializable JavaDoc;
9
10 import org.springframework.beans.support.MutableSortDefinition;
11 import org.springframework.beans.support.PropertyComparator;
12
13 /**
14  * Simple JavaBean domain object representing a veterinarian.
15  *
16  * @author Ken Krebs
17  * @author Juergen Hoeller
18  */

19 public class Vet extends Person{
20
21     private Set JavaDoc specialties;
22
23     protected void setSpecialtiesInternal(Set JavaDoc specialties) {
24         this.specialties = specialties;
25     }
26
27     protected Set JavaDoc getSpecialtiesInternal() {
28         if (this.specialties == null) {
29             this.specialties = new HashSet JavaDoc();
30         }
31         return this.specialties;
32     }
33
34     public List JavaDoc getSpecialties() {
35         List JavaDoc sortedSpecs = new ArrayList JavaDoc(getSpecialtiesInternal());
36         PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true, true));
37         return Collections.unmodifiableList(sortedSpecs);
38     }
39
40     public int getNrOfSpecialties() {
41         return getSpecialtiesInternal().size();
42     }
43
44     public void addSpecialty(Specialty specialty) {
45         getSpecialtiesInternal().add(specialty);
46     }
47
48 }
49
Popular Tags