Roles added
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Reservation.java
index 2aa7c0d..29689a6 100644 (file)
@@ -7,24 +7,40 @@
  */\r
 package ch.bfh.ti.srs.dataschema;\r
 \r
+import java.util.UUID;\r
+\r
 import ch.bfh.ti.daterange.DateRange;\r
 \r
-public class Reservation {\r
+public class Reservation implements Modify {\r
 \r
-       private String name;\r
+       private UUID id;\r
+       private UUID groupId;\r
        private User user;\r
        private Resource resource;\r
        private DateRange dateRange;\r
+       private String remark;\r
+\r
+       public Reservation(UUID groupId, User user, Resource resource, DateRange DateRange, String remark) {\r
+               if (user == null)\r
+                       throw new IllegalArgumentException("User must not be null");\r
+               if (resource == null)\r
+                       throw new IllegalArgumentException("Resource must not be null");\r
 \r
-       public Reservation(String name, User user, Resource resource, DateRange DateRange) {\r
-               this.name = name;\r
+               this.groupId = groupId;\r
                this.user = user;\r
                this.resource = resource;\r
                this.dateRange = DateRange;\r
+               this.remark = remark;\r
+\r
+               this.id = UUID.randomUUID();\r
        }\r
 \r
-       public String getName() {\r
-               return name;\r
+       public UUID getId() {\r
+               return id;\r
+       }\r
+\r
+       public UUID getGroupId() {\r
+               return groupId;\r
        }\r
 \r
        public User getUser() {\r
@@ -39,8 +55,8 @@ public class Reservation {
                return dateRange;\r
        }\r
 \r
-       public void setName(String name) {\r
-               this.name = name;\r
+       public String getRemark() {\r
+               return remark;\r
        }\r
 \r
        public void setUser(User user) {\r
@@ -54,4 +70,27 @@ public class Reservation {
        public void setDateRange(DateRange dateRange) {\r
                this.dateRange = dateRange;\r
        }\r
+\r
+       public void setRemark(String remark) {\r
+               this.remark = remark;\r
+       }\r
+\r
+       @Override\r
+       public boolean isModified(Object obj) {\r
+               if (obj == this) {\r
+                       return false;\r
+               }\r
+               if (obj == null) {\r
+                       return true;\r
+               }\r
+               Reservation otherReservation = (Reservation) obj;\r
+               return this.user != otherReservation.getUser() || this.resource != otherReservation.getResource()\r
+                               || this.dateRange.compareTo(otherReservation.getDateRange()) != 0\r
+                               || this.remark != otherReservation.getRemark();\r
+       }\r
+\r
+       @Override\r
+       public Reservation clone() throws CloneNotSupportedException {\r
+               return (Reservation) super.clone();\r
+       }\r
 }\r