1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class MyInventoryStaticImpl
28 extends
29 MyInventoryStatic
30 {
31
32
33
34
35
36
37 public MyInventoryStaticImpl()
38 {
39 }
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 public MyInventoryStaticImpl(
81 UnrealId Id, ItemType Type, ItemDescriptor Descriptor
82 ) {
83
84 this.Id = Id;
85
86 this.Type = Type;
87
88 this.Descriptor = Descriptor;
89
90 }
91
92
93
94
95
96
97 public MyInventoryStaticImpl(MyInventory original) {
98
99 this.Id = original.getId()
100 ;
101
102 this.Type = original.getType()
103 ;
104
105 this.Descriptor = original.getDescriptor()
106 ;
107
108 this.SimTime = original.getSimTime();
109 }
110
111
112
113
114
115
116 public MyInventoryStaticImpl(MyInventoryStaticImpl original) {
117
118 this.Id = original.getId()
119 ;
120
121 this.Type = original.getType()
122 ;
123
124 this.Descriptor = original.getDescriptor()
125 ;
126
127 this.SimTime = original.getSimTime();
128 }
129
130
131
132
133
134
135 public MyInventoryStaticImpl(MyInventoryStatic original) {
136
137 this.Id = original.getId()
138 ;
139
140 this.Type = original.getType()
141 ;
142
143 this.Descriptor = original.getDescriptor()
144 ;
145
146 }
147
148
149 @Override
150 public void setSimTime(long SimTime) {
151 super.setSimTime(SimTime);
152 }
153
154 @Override
155 public
156 MyInventoryStaticImpl clone() {
157 return new
158 MyInventoryStaticImpl(this);
159 }
160
161
162
163
164
165
166
167
168 protected
169 UnrealId Id =
170 null;
171
172
173
174
175
176
177 public UnrealId getId()
178 {
179 return Id;
180 }
181
182
183
184
185
186
187
188 protected
189 ItemType Type =
190 null;
191
192
193
194
195
196
197 public ItemType getType()
198 {
199 return Type;
200 }
201
202
203
204
205
206
207
208 protected
209 ItemDescriptor Descriptor =
210 null;
211
212
213
214
215
216
217 public ItemDescriptor getDescriptor()
218 {
219 return Descriptor;
220 }
221
222
223
224 public static class MyInventoryStaticUpdate
225 implements IStaticWorldObjectUpdatedEvent
226 {
227
228 private MyInventoryStatic data;
229 private long time;
230
231 public MyInventoryStaticUpdate
232 (MyInventoryStatic source, long time)
233 {
234 this.data = source;
235 this.time = time;
236 }
237
238
239
240
241 @Override
242 public long getSimTime() {
243 return time;
244 }
245
246 @Override
247 public WorldObjectId getId() {
248 return data.getId();
249 }
250
251 @Override
252 public IWorldObjectUpdateResult<IStaticWorldObject> update(
253 IStaticWorldObject object) {
254 if ( object == null)
255 {
256 data = new MyInventoryStaticImpl(data);
257 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
258 }
259
260 if ( object instanceof MyInventoryStaticImpl)
261 {
262 MyInventoryStaticImpl orig = (MyInventoryStaticImpl)object;
263
264 if ( data.isDifferentFrom(orig) )
265 {
266
267
268 System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : MyInventoryStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
269 }
270 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
271 }
272 throw new PogamutException("Unexpected object type for update, MyInventoryStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
273 }
274 }
275
276
277
278 @Override
279 public boolean isDifferentFrom(IStaticWorldObject other)
280 {
281 if (other == null)
282 {
283 return true;
284 }
285 else if (other == this)
286 {
287 return false;
288 }
289 else
290 {
291 MyInventoryStatic obj = (MyInventoryStatic) other;
292
293
294 if ( !(
295 AdvancedEquals.equalsOrNull(this.getId()
296 , obj.getId()
297 )
298 ) )
299 {
300 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class MyInventoryStatic");
301 return true;
302 }
303
304 if ( !(
305 AdvancedEquals.equalsOrNull(this.getType()
306 , obj.getType()
307 )
308 ) )
309 {
310 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Type on object class MyInventoryStatic");
311 return true;
312 }
313
314 if ( !(
315 AdvancedEquals.equalsOrNull(this.getDescriptor()
316 , obj.getDescriptor()
317 )
318 ) )
319 {
320 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Descriptor on object class MyInventoryStatic");
321 return true;
322 }
323
324 }
325 return false;
326 }
327
328
329 public String toString() {
330 return
331 super.toString() + "[" +
332
333 "Id = " + String.valueOf(getId()
334 ) + " | " +
335
336 "Type = " + String.valueOf(getType()
337 ) + " | " +
338
339 "]";
340 }
341
342
343 public String toHtmlString() {
344 return super.toString() + "[<br/>" +
345
346 "<b>Id</b> = " + String.valueOf(getId()
347 ) + " <br/> " +
348
349 "<b>Type</b> = " + String.valueOf(getType()
350 ) + " <br/> " +
351
352 "<br/>]";
353 }
354
355
356
357
358
359
360
361
362
363
364 }
365