View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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 net.sf.ehcache.hibernate.domain;
18  
19  import java.util.ArrayList;
20  import java.util.HashSet;
21  import java.util.List;
22  import java.util.Set;
23  
24  public class Person {
25  
26      private Long id;
27      private int age;
28      private String firstname;
29      private String lastname;
30      private List events = new ArrayList(); // list semantics, e.g., indexed
31      private Set emailAddresses = new HashSet();
32      private Set phoneNumbers = new HashSet();
33      private List talismans = new ArrayList(); // a Bag of good-luck charms.
34  
35      public Person() {
36          //
37      }
38  
39      public List getEvents() {
40          return events;
41      }
42  
43      protected void setEvents(List events) {
44          this.events = events;
45      }
46  
47      public void addToEvent(Event event) {
48          this.getEvents().add(event);
49          event.getParticipants().add(this);
50      }
51  
52      public void removeFromEvent(Event event) {
53          this.getEvents().remove(event);
54          event.getParticipants().remove(this);
55      }
56  
57      public int getAge() {
58          return age;
59      }
60  
61      public void setAge(int age) {
62          this.age = age;
63      }
64  
65      public String getFirstname() {
66          return firstname;
67      }
68  
69      public void setFirstname(String firstname) {
70          this.firstname = firstname;
71      }
72  
73      public Long getId() {
74          return id;
75      }
76  
77      public void setId(Long id) {
78          this.id = id;
79      }
80  
81      public String getLastname() {
82          return lastname;
83      }
84  
85      public void setLastname(String lastname) {
86          this.lastname = lastname;
87      }
88  
89      public Set getEmailAddresses() {
90          return emailAddresses;
91      }
92  
93      public void setEmailAddresses(Set emailAddresses) {
94          this.emailAddresses = emailAddresses;
95      }
96  
97      public Set getPhoneNumbers() {
98          return phoneNumbers;
99      }
100 
101     public void setPhoneNumbers(Set phoneNumbers) {
102         this.phoneNumbers = phoneNumbers;
103     }
104 
105     public void addTalisman(String name) {
106         talismans.add(name);
107     }
108 
109     public List getTalismans() {
110         return talismans;
111     }
112 
113     public void setTalismans(List talismans) {
114         this.talismans = talismans;
115     }
116 
117     public String toString() {
118         return getFirstname() + " " + getLastname();
119     }
120 }