1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.calendar.service;
18
19 public class Invitation {
20
21 private String eventId;
22
23 private String participant;
24
25 private String status;
26
27 public Invitation(String eventId, String participant, String status) {
28 this.eventId = eventId;
29 this.participant = participant;
30 this.status = status;
31 }
32
33 public String getId() {
34 return String.format("%s:%s", eventId, participant);
35 }
36
37 public String getEventId() {
38 return eventId;
39 }
40
41 public String getParticipant() {
42 return participant;
43 }
44
45 public String getStatus() {
46 return status;
47 }
48
49 @Override
50 public int hashCode() {
51 final int prime = 31;
52 int result = 1;
53 result = prime * result + ((eventId == null) ? 0 : eventId.hashCode());
54 result = prime * result + ((participant == null) ? 0 : participant.hashCode());
55 result = prime * result + ((status == null) ? 0 : status.hashCode());
56 return result;
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj)
62 return true;
63 if (obj == null)
64 return false;
65 if (getClass() != obj.getClass())
66 return false;
67 Invitation other = (Invitation) obj;
68 if (eventId == null) {
69 if (other.eventId != null)
70 return false;
71 } else if (!eventId.equals(other.eventId))
72 return false;
73 if (participant == null) {
74 if (other.participant != null)
75 return false;
76 } else if (!participant.equals(other.participant))
77 return false;
78 if (status == null) {
79 if (other.status != null)
80 return false;
81 } else if (!status.equals(other.status))
82 return false;
83 return true;
84 }
85
86 public static String[] parse(String id) {
87 if (id == null) {
88 throw new IllegalArgumentException("id should not be null");
89 }
90
91 String[] tmp = id.split(":");
92 if (tmp.length != 2) {
93 throw new IllegalArgumentException("id should be compose of eventId:participantId");
94 }
95 return tmp;
96 }
97 }