]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Table.java
Show orders in PizzeriaGUI
[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 /**
11  * A table is a thing, where people can put things at. Possibly a laptop, to
12  * have free hands to hold a pizzabox on the knees.
13  * 
14  * @author jan
15  * 
16  */
17 @Queryable(autoindex=true)
18 public class Table implements Serializable, HasId {
19         private static int idNext = 0;
20         private final Integer id;
21
22         private Integer groupId = -1;
23
24         public Table(Integer id) {
25                 this.id = id;
26         }
27
28         public Table() {
29                 id = ++idNext;
30         }
31
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 + "]";
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         
81
82 }