Roles added
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Reservation.java
... / ...
CommitLineData
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
10import java.util.UUID;\r
11\r
12import ch.bfh.ti.daterange.DateRange;\r
13\r
14public class Reservation implements Modify {\r
15\r
16 private UUID id;\r
17 private UUID groupId;\r
18 private User user;\r
19 private Resource resource;\r
20 private DateRange dateRange;\r
21 private String remark;\r
22\r
23 public Reservation(UUID groupId, User user, Resource resource, DateRange DateRange, String remark) {\r
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
28\r
29 this.groupId = groupId;\r
30 this.user = user;\r
31 this.resource = resource;\r
32 this.dateRange = DateRange;\r
33 this.remark = remark;\r
34\r
35 this.id = UUID.randomUUID();\r
36 }\r
37\r
38 public UUID getId() {\r
39 return id;\r
40 }\r
41\r
42 public UUID getGroupId() {\r
43 return groupId;\r
44 }\r
45\r
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
58 public String getRemark() {\r
59 return remark;\r
60 }\r
61\r
62 public void setUser(User user) {\r
63 this.user = user;\r
64 }\r
65\r
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
73\r
74 public void setRemark(String remark) {\r
75 this.remark = remark;\r
76 }\r
77\r
78 @Override\r
79 public boolean isModified(Object obj) {\r
80 if (obj == this) {\r
81 return false;\r
82 }\r
83 if (obj == null) {\r
84 return true;\r
85 }\r
86 Reservation otherReservation = (Reservation) obj;\r
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
92 @Override\r
93 public Reservation clone() throws CloneNotSupportedException {\r
94 return (Reservation) super.clone();\r
95 }\r
96}\r