01: package events;
02:
03: import java.util.*;
04:
05: public class Person {
06:
07: private Long id;
08: private int age;
09: private String firstname;
10: private String lastname;
11:
12: public Person() {
13: }
14:
15: public Long getId() {
16: return id;
17: }
18:
19: public void setId(Long id) {
20: this .id = id;
21: }
22:
23: public int getAge() {
24: return age;
25: }
26:
27: public void setAge(int age) {
28: this .age = age;
29: }
30:
31: public String getFirstname() {
32: return firstname;
33: }
34:
35: public void setFirstname(String firstname) {
36: this .firstname = firstname;
37: }
38:
39: public String getLastname() {
40: return lastname;
41: }
42:
43: public void setLastname(String lastname) {
44: this .lastname = lastname;
45: }
46:
47: private Set emailAddresses = new HashSet();
48:
49: public Set getEmailAddresses() {
50: return emailAddresses;
51: }
52:
53: public void setEmailAddresses(Set emailAddresses) {
54: this .emailAddresses = emailAddresses;
55: }
56:
57: private Set events = new HashSet();
58:
59: // Defensive, convenience methods
60: protected Set getEvents() {
61: return events;
62: }
63:
64: protected void setEvents(Set events) {
65: this .events = events;
66: }
67:
68: public void addToEvent(Event event) {
69: this .getEvents().add(event);
70: event.getParticipants().add(this );
71: }
72:
73: public void removeFromEvent(Event event) {
74: this.getEvents().remove(event);
75: event.getParticipants().remove(this);
76: }
77:
78: }
|