]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Table.java
JMS: pizzeriaGui now displays everything correctly.
[pub/jan/sbc.git] / src / main / java / at / ac / tuwien / sbc / valesriegler / types / Table.java
1 package at.ac.tuwien.sbc.valesriegler.types;
2
3 import java.io.Serializable;
4
5 import org.mozartspaces.capi3.Queryable;
6
7 import at.ac.tuwien.sbc.valesriegler.common.HasId;
8
9 /**
10  * A table is a thing, where people can put things at. Possibly a laptop, to
11  * have free hands to hold a pizzabox on the knees.
12  * 
13  * @author jan
14  * 
15  */
16 @Queryable(autoindex = true)
17 public class Table implements Serializable, HasId {
18         private static int idNext = 0;
19         private final Integer id;
20
21         private Integer groupId = -1;
22
23         public Table(Integer id) {
24                 this.id = id;
25         }
26
27         public Table() {
28                 id = ++idNext;
29         }
30
31         @Override
32         public int getId() {
33                 return id;
34         }
35
36         public int getGroupId() {
37                 return groupId;
38         }
39
40         public void setGroupId(int groupId) {
41                 this.groupId = groupId;
42         }
43
44         public boolean isFree() {
45                 if (groupId == -1)
46                         return true;
47                 return false;
48         }
49
50         @Override
51         public String toString() {
52                 return "Table [id=" + id + ", groupId=" + groupId + "]";
53         }
54
55         @Override
56         public int hashCode() {
57                 final int prime = 31;
58                 int result = 1;
59                 result = prime * result + ((id == null) ? 0 : id.hashCode());
60                 return result;
61         }
62
63         @Override
64         public boolean equals(Object obj) {
65                 if (this == obj)
66                         return true;
67                 if (obj == null)
68                         return false;
69                 if (getClass() != obj.getClass())
70                         return false;
71                 Table other = (Table) obj;
72                 if (id == null) {
73                         if (other.id != null)
74                                 return false;
75                 } else if (!id.equals(other.id))
76                         return false;
77                 return true;
78         }
79
80 }