Roles added
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Reservation.java
index fd7da2b..29689a6 100644 (file)
@@ -11,7 +11,7 @@ import java.util.UUID;
 \r
 import ch.bfh.ti.daterange.DateRange;\r
 \r
-public class Reservation implements Cloneable {\r
+public class Reservation implements Modify {\r
 \r
        private UUID id;\r
        private UUID groupId;\r
@@ -21,14 +21,10 @@ public class Reservation implements Cloneable {
        private String remark;\r
 \r
        public Reservation(UUID groupId, User user, Resource resource, DateRange DateRange, String remark) {\r
-               // // if (groupId == null)\r
-               // // throw new IllegalArgumentException("GroupID must not be null");\r
-               // if (user.getUserName() == null)\r
-               // throw new IllegalArgumentException("User must not be null");\r
-               // if (resource.getId() == null)\r
-               // throw new IllegalArgumentException("Resource must not be null");\r
-               // if (dateRange.isEmpty())\r
-               // throw new IllegalArgumentException("DateRange must not be null");\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
                this.groupId = groupId;\r
                this.user = user;\r
@@ -80,6 +76,20 @@ public class Reservation implements Cloneable {
        }\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