Roles added
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Resource.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
12public class Resource implements Modify {\r
13\r
14 private UUID id;\r
15 private String name;\r
16 private String type;\r
17\r
18 /**\r
19 * Normal constructor for new resources created in the UserController\r
20 * @param name\r
21 * this is the name of the resource\r
22 * @param type\r
23 * this is the type for example school,meeting room...\r
24 * @throws Exception\r
25 * the name of the resource can't be null\r
26 */\r
27\r
28 public Resource(String name, String type) throws Exception {\r
29 if (name == null)\r
30 throw new IllegalArgumentException("Name must not be null");\r
31\r
32 this.name = name;\r
33 this.type = type;\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 String getName() {\r
43 return name;\r
44 }\r
45\r
46 public String getType() {\r
47 return type;\r
48 }\r
49\r
50 public void setName(String name) {\r
51 this.name = name;\r
52 }\r
53\r
54 public void setType(String type) {\r
55 this.type = type;\r
56 }\r
57\r
58 public boolean isModified(Object obj) {\r
59 if (obj == this) {\r
60 return false;\r
61 }\r
62 if (obj == null) {\r
63 return true;\r
64 }\r
65 Resource otherResource = (Resource) obj;\r
66 return this.name != otherResource.getName() || this.type != otherResource.getType();\r
67 }\r
68\r
69 @Override\r
70 public Resource clone() throws CloneNotSupportedException {\r
71 return (Resource) super.clone();\r
72 }\r
73}\r