01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.sample.petclinic;
18:
19: import java.util.ArrayList;
20: import java.util.Collections;
21: import java.util.HashSet;
22: import java.util.List;
23: import java.util.Set;
24:
25: import org.springframework.beans.support.MutableSortDefinition;
26: import org.springframework.beans.support.PropertyComparator;
27:
28: /**
29: * Simple JavaBean domain object representing a veterinarian.
30: *
31: * @author Ken Krebs
32: * @author Juergen Hoeller
33: */
34: public class Vet extends Person {
35:
36: private Set specialties;
37:
38: protected void setSpecialtiesInternal(Set specialties) {
39: this .specialties = specialties;
40: }
41:
42: protected Set getSpecialtiesInternal() {
43: if (this .specialties == null) {
44: this .specialties = new HashSet();
45: }
46: return this .specialties;
47: }
48:
49: public List getSpecialties() {
50: List sortedSpecs = new ArrayList(getSpecialtiesInternal());
51: PropertyComparator.sort(sortedSpecs, new MutableSortDefinition(
52: "name", true, true));
53: return Collections.unmodifiableList(sortedSpecs);
54: }
55:
56: public int getNrOfSpecialties() {
57: return getSpecialtiesInternal().size();
58: }
59:
60: public void addSpecialty(Specialty specialty) {
61: getSpecialtiesInternal().add(specialty);
62: }
63: }
|