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