Create ResourceManagerController, create Modify interface in dataschema,
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / dataschema / Resource.java
CommitLineData
9a78ca13
MT
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
a49c468f
MT
10import java.util.UUID;\r
11\r
5fca88b4 12public class Resource implements Modify {\r
9a78ca13 13\r
a49c468f 14 private UUID id;\r
9a78ca13
MT
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
66cc653d
D
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
9a78ca13
MT
26 */\r
27\r
a49c468f 28 public Resource(String name, String type) throws Exception {\r
9a78ca13
MT
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
a49c468f
MT
34\r
35 this.id = UUID.randomUUID();\r
36 }\r
37\r
38 public UUID getId() {\r
39 return id;\r
9a78ca13
MT
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
66cc653d 57\r
5fca88b4
MT
58 public boolean isModified(Object obj) {\r
59 if (obj == this) {\r
912c75db
MT
60 return false;\r
61 }\r
5fca88b4 62 if (obj == null) {\r
912c75db
MT
63 return true;\r
64 }\r
5fca88b4 65 Resource otherResource = (Resource) obj;\r
912c75db
MT
66 return this.name != otherResource.getName() || this.type != otherResource.getType();\r
67 }\r
68\r
a08b0437
M
69 @Override\r
70 public Resource clone() throws CloneNotSupportedException {\r
66cc653d
D
71 return (Resource) super.clone();\r
72 }\r
9a78ca13 73}\r