Added isModified method to Resource, Reservation.
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Reservation.java
index fd7da2b..1588900 100644 (file)
@@ -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
@@ -79,6 +75,18 @@ public class Reservation implements Cloneable {
                this.remark = remark;\r
        }\r
 \r
+       public boolean isModified(Reservation otherReservation) {\r
+               if (otherReservation == this) {\r
+                       return false;\r
+               }\r
+               if (otherReservation == null) {\r
+                       return true;\r
+               }\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