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