1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hiveboard; |
16 | |
17 | import java.util.Arrays; |
18 | import java.util.Date; |
19 | |
20 | import org.apache.hivemind.util.ToStringBuilder; |
21 | |
22 | public class Event |
23 | { |
24 | public EventType getType() |
25 | { |
26 | return _type; |
27 | } |
28 | public void setType(EventType type) |
29 | { |
30 | _type = type; |
31 | } |
32 | |
33 | public Date getWhen() |
34 | { |
35 | return _when; |
36 | } |
37 | public void setWhen(Date when) |
38 | { |
39 | _when = when; |
40 | } |
41 | |
42 | public int getWho() |
43 | { |
44 | return _who; |
45 | } |
46 | public void setWho(int who) |
47 | { |
48 | _who = who; |
49 | } |
50 | |
51 | public int getWhere() |
52 | { |
53 | return _where; |
54 | } |
55 | public void setWhere(int where) |
56 | { |
57 | _where = where; |
58 | } |
59 | |
60 | public String getComment() |
61 | { |
62 | return _comment; |
63 | } |
64 | public void setComment(String comment) |
65 | { |
66 | _comment = comment; |
67 | } |
68 | |
69 | public byte[] getDrawingAction() |
70 | { |
71 | return _drawingAction; |
72 | } |
73 | public void setDrawingAction(byte[] drawingAction) |
74 | { |
75 | _drawingAction = drawingAction; |
76 | } |
77 | |
78 | public byte[] getRaster() |
79 | { |
80 | return _raster; |
81 | } |
82 | public void setRaster(byte[] raster) |
83 | { |
84 | _raster = raster; |
85 | } |
86 | |
87 | public Board getBoard() |
88 | { |
89 | return _board; |
90 | } |
91 | public void setBoard(Board board) |
92 | { |
93 | _board = board; |
94 | } |
95 | |
96 | public Account getAccount() |
97 | { |
98 | return _account; |
99 | } |
100 | public void setAccount(Account account) |
101 | { |
102 | _account = account; |
103 | } |
104 | |
105 | @Override public String toString() |
106 | { |
107 | ToStringBuilder builder = new ToStringBuilder(this); |
108 | builder.append("type", _type); |
109 | builder.append("who", _who); |
110 | builder.append("where", _where); |
111 | return builder.toString(); |
112 | } |
113 | |
114 | @Override public int hashCode() |
115 | { |
116 | return (int) _when.getTime(); |
117 | } |
118 | |
119 | @Override public boolean equals(Object o) |
120 | { |
121 | if (!(o instanceof Event)) |
122 | { |
123 | return false; |
124 | } |
125 | Event that = (Event) o; |
126 | return ( (this._type == that._type) |
127 | && (this._when.getTime() == that._when.getTime()) |
128 | && (this._who == that._who) |
129 | && (this._where == that._where) |
130 | && equals(this._comment, that._comment) |
131 | && equals(this._board, that._board) |
132 | && equals(this._account, that._account) |
133 | && Arrays.equals(this._drawingAction, that._drawingAction) |
134 | && Arrays.equals(this._raster, that._raster)); |
135 | } |
136 | |
137 | static private boolean equals(Object o1, Object o2) |
138 | { |
139 | if (o1 == o2) |
140 | { |
141 | return true; |
142 | } |
143 | if (o1 == null || o2 == null) |
144 | { |
145 | return false; |
146 | } |
147 | if (o1.hashCode() != o2.hashCode()) |
148 | { |
149 | return false; |
150 | } |
151 | return o1.equals(o2); |
152 | } |
153 | |
154 | private EventType _type; |
155 | private Date _when = new Date(); |
156 | private int _who; |
157 | private int _where; |
158 | private String _comment; |
159 | private byte[] _drawingAction; |
160 | private byte[] _raster; |
161 | private Board _board; |
162 | private Account _account; |
163 | } |