]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Table.java
Some space refactoring. Doing away with unnecessary containers. Auto-Reloading of...
[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
51         
52         @Override
53         public String toString() {
54                 return "Table [id=" + id + ", groupId=" + groupId + "]";
55         }
56
57         @Override
58         public int hashCode() {
59                 final int prime = 31;
60                 int result = 1;
61                 result = prime * result + ((id == null) ? 0 : id.hashCode());
62                 return result;
63         }
64
65         @Override
66         public boolean equals(Object obj) {
67                 if (this == obj)
68                         return true;
69                 if (obj == null)
70                         return false;
71                 if (getClass() != obj.getClass())
72                         return false;
73                 Table other = (Table) obj;
74                 if (id == null) {
75                         if (other.id != null)
76                                 return false;
77                 } else if (!id.equals(other.id))
78                         return false;
79                 return true;
80         }
81         
82         
83
84 }