1 package org.springframework.samples.petclinic; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.HashSet ; 6 import java.util.List ; 7 import java.util.Set ; 8 import java.io.Serializable ; 9 10 import org.springframework.beans.support.MutableSortDefinition; 11 import org.springframework.beans.support.PropertyComparator; 12 13 19 public class Vet extends Person{ 20 21 private Set specialties; 22 23 protected void setSpecialtiesInternal(Set specialties) { 24 this.specialties = specialties; 25 } 26 27 protected Set getSpecialtiesInternal() { 28 if (this.specialties == null) { 29 this.specialties = new HashSet (); 30 } 31 return this.specialties; 32 } 33 34 public List getSpecialties() { 35 List sortedSpecs = new ArrayList (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 |