Roles added
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Reservation.java
CommitLineData
9a78ca13
MT
1/*\r
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.\r
3 *\r
4 * Project Smart Reservation System.\r
5 *\r
6 * Distributable under GPL license. See terms of license at gnu.org.\r
7 */\r
8package ch.bfh.ti.srs.dataschema;\r
9\r
81c3aac6
MT
10import java.util.UUID;\r
11\r
9a78ca13
MT
12import ch.bfh.ti.daterange.DateRange;\r
13\r
5fca88b4 14public class Reservation implements Modify {\r
9a78ca13 15\r
81c3aac6
MT
16 private UUID id;\r
17 private UUID groupId;\r
9a78ca13
MT
18 private User user;\r
19 private Resource resource;\r
20 private DateRange dateRange;\r
81c3aac6
MT
21 private String remark;\r
22\r
a49c468f 23 public Reservation(UUID groupId, User user, Resource resource, DateRange DateRange, String remark) {\r
912c75db
MT
24 if (user == null)\r
25 throw new IllegalArgumentException("User must not be null");\r
26 if (resource == null)\r
27 throw new IllegalArgumentException("Resource must not be null");\r
9a78ca13 28\r
a49c468f 29 this.groupId = groupId;\r
9a78ca13
MT
30 this.user = user;\r
31 this.resource = resource;\r
32 this.dateRange = DateRange;\r
81c3aac6 33 this.remark = remark;\r
66cc653d 34\r
a49c468f 35 this.id = UUID.randomUUID();\r
9a78ca13
MT
36 }\r
37\r
a49c468f
MT
38 public UUID getId() {\r
39 return id;\r
40 }\r
66cc653d 41\r
a49c468f
MT
42 public UUID getGroupId() {\r
43 return groupId;\r
44 }\r
66cc653d 45\r
9a78ca13
MT
46 public User getUser() {\r
47 return user;\r
48 }\r
49\r
50 public Resource getResource() {\r
51 return resource;\r
52 }\r
53\r
54 public DateRange getDateRange() {\r
55 return dateRange;\r
56 }\r
57\r
81c3aac6
MT
58 public String getRemark() {\r
59 return remark;\r
9a78ca13 60 }\r
66cc653d 61\r
9a78ca13
MT
62 public void setUser(User user) {\r
63 this.user = user;\r
64 }\r
66cc653d 65\r
9a78ca13
MT
66 public void setResource(Resource resource) {\r
67 this.resource = resource;\r
68 }\r
69\r
70 public void setDateRange(DateRange dateRange) {\r
71 this.dateRange = dateRange;\r
72 }\r
81c3aac6
MT
73\r
74 public void setRemark(String remark) {\r
75 this.remark = remark;\r
76 }\r
66cc653d 77\r
5fca88b4
MT
78 @Override\r
79 public boolean isModified(Object obj) {\r
80 if (obj == this) {\r
912c75db
MT
81 return false;\r
82 }\r
5fca88b4 83 if (obj == null) {\r
912c75db
MT
84 return true;\r
85 }\r
5fca88b4 86 Reservation otherReservation = (Reservation) obj;\r
912c75db
MT
87 return this.user != otherReservation.getUser() || this.resource != otherReservation.getResource()\r
88 || this.dateRange.compareTo(otherReservation.getDateRange()) != 0\r
89 || this.remark != otherReservation.getRemark();\r
90 }\r
91\r
a08b0437
M
92 @Override\r
93 public Reservation clone() throws CloneNotSupportedException {\r
66cc653d
D
94 return (Reservation) super.clone();\r
95 }\r
9a78ca13 96}\r