View Javadoc

1   
2       		/**
3            	IMPORTANT !!!
4   
5            	DO NOT EDIT THIS FILE. IT IS GENERATED FROM 
6            	THE JavaClassesGenerator.xslt. MODIFY THAT FILE INSTEAD OF THIS ONE.
7            
8            	Use Ant task process-gb-messages after that to generate this file again.
9            
10           	IMPORTANT END !!!
11          	*/
12   			   	
13      		package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
14  
15              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.*;
16  
17              public class UT2004CompositeObjectCreator {
18  	
19  				public static interface ICompositeWorldObjectCreator<T extends ICompositeWorldObject> {
20  					
21  					public T create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart);
22  					
23  				}
24  				
25  				
26  					public static class SelfCreator implements ICompositeWorldObjectCreator<Self> {
27  						
28  						@Override
29  						public Self
30  							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
31  						{
32  							return 
33  								new
34  								SelfCompositeImpl 
35  								( 
36  								 new
37  								  SelfLocalImpl
38  								 ((SelfLocal
39  								  )localPart
40  								 ), 
41  								 new
42  								  SelfSharedImpl
43  								 (
44  								 	sharedPart.getId(), sharedPart.getProperties().values()
45  								 ), 
46  								 new
47  								  SelfStaticImpl
48  								 ((SelfStatic
49  								  )staticPart
50  								 )
51  								)
52  							;
53  						}
54  					}
55  				
56  				
57  					public static class BombInfoCreator implements ICompositeWorldObjectCreator<BombInfo> {
58  						
59  						@Override
60  						public BombInfo
61  							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
62  						{
63  							return 
64  								new
65  								BombInfoCompositeImpl 
66  								( 
67  								 new
68  								  BombInfoLocalImpl
69  								 ((BombInfoLocal
70  								  )localPart
71  								 ), 
72  								 new
73  								  BombInfoSharedImpl
74  								 (
75  								 	sharedPart.getId(), sharedPart.getProperties().values()
76  								 ), 
77  								 new
78  								  BombInfoStaticImpl
79  								 ((BombInfoStatic
80  								  )staticPart
81  								 )
82  								)
83  							;
84  						}
85  					}
86  				
87  				
88  					public static class FlagInfoCreator implements ICompositeWorldObjectCreator<FlagInfo> {
89  						
90  						@Override
91  						public FlagInfo
92  							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
93  						{
94  							return 
95  								new
96  								FlagInfoCompositeImpl 
97  								( 
98  								 new
99  								  FlagInfoLocalImpl
100 								 ((FlagInfoLocal
101 								  )localPart
102 								 ), 
103 								 new
104 								  FlagInfoSharedImpl
105 								 (
106 								 	sharedPart.getId(), sharedPart.getProperties().values()
107 								 ), 
108 								 new
109 								  FlagInfoStaticImpl
110 								 ((FlagInfoStatic
111 								  )staticPart
112 								 )
113 								)
114 							;
115 						}
116 					}
117 				
118 				
119 					public static class InitedMessageCreator implements ICompositeWorldObjectCreator<InitedMessage> {
120 						
121 						@Override
122 						public InitedMessage
123 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
124 						{
125 							return 
126 								new
127 								InitedMessageCompositeImpl 
128 								( 
129 								 new
130 								  InitedMessageLocalImpl
131 								 ((InitedMessageLocal
132 								  )localPart
133 								 ), 
134 								 new
135 								  InitedMessageSharedImpl
136 								 (
137 								 	sharedPart.getId(), sharedPart.getProperties().values()
138 								 ), 
139 								 new
140 								  InitedMessageStaticImpl
141 								 ((InitedMessageStatic
142 								  )staticPart
143 								 )
144 								)
145 							;
146 						}
147 					}
148 				
149 				
150 					public static class TeamScoreCreator implements ICompositeWorldObjectCreator<TeamScore> {
151 						
152 						@Override
153 						public TeamScore
154 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
155 						{
156 							return 
157 								new
158 								TeamScoreCompositeImpl 
159 								( 
160 								 new
161 								  TeamScoreLocalImpl
162 								 ((TeamScoreLocal
163 								  )localPart
164 								 ), 
165 								 new
166 								  TeamScoreSharedImpl
167 								 (
168 								 	sharedPart.getId(), sharedPart.getProperties().values()
169 								 ), 
170 								 new
171 								  TeamScoreStaticImpl
172 								 ((TeamScoreStatic
173 								  )staticPart
174 								 )
175 								)
176 							;
177 						}
178 					}
179 				
180 				
181 					public static class AutoTraceRayCreator implements ICompositeWorldObjectCreator<AutoTraceRay> {
182 						
183 						@Override
184 						public AutoTraceRay
185 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
186 						{
187 							return 
188 								new
189 								AutoTraceRayCompositeImpl 
190 								( 
191 								 new
192 								  AutoTraceRayLocalImpl
193 								 ((AutoTraceRayLocal
194 								  )localPart
195 								 ), 
196 								 new
197 								  AutoTraceRaySharedImpl
198 								 (
199 								 	sharedPart.getId(), sharedPart.getProperties().values()
200 								 ), 
201 								 new
202 								  AutoTraceRayStaticImpl
203 								 ((AutoTraceRayStatic
204 								  )staticPart
205 								 )
206 								)
207 							;
208 						}
209 					}
210 				
211 				
212 					public static class MoverCreator implements ICompositeWorldObjectCreator<Mover> {
213 						
214 						@Override
215 						public Mover
216 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
217 						{
218 							return 
219 								new
220 								MoverCompositeImpl 
221 								( 
222 								 new
223 								  MoverLocalImpl
224 								 ((MoverLocal
225 								  )localPart
226 								 ), 
227 								 new
228 								  MoverSharedImpl
229 								 (
230 								 	sharedPart.getId(), sharedPart.getProperties().values()
231 								 ), 
232 								 new
233 								  MoverStaticImpl
234 								 ((MoverStatic
235 								  )staticPart
236 								 )
237 								)
238 							;
239 						}
240 					}
241 				
242 				
243 					public static class ConfigChangeCreator implements ICompositeWorldObjectCreator<ConfigChange> {
244 						
245 						@Override
246 						public ConfigChange
247 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
248 						{
249 							return 
250 								new
251 								ConfigChangeCompositeImpl 
252 								( 
253 								 new
254 								  ConfigChangeLocalImpl
255 								 ((ConfigChangeLocal
256 								  )localPart
257 								 ), 
258 								 new
259 								  ConfigChangeSharedImpl
260 								 (
261 								 	sharedPart.getId(), sharedPart.getProperties().values()
262 								 ), 
263 								 new
264 								  ConfigChangeStaticImpl
265 								 ((ConfigChangeStatic
266 								  )staticPart
267 								 )
268 								)
269 							;
270 						}
271 					}
272 				
273 				
274 					public static class VehicleCreator implements ICompositeWorldObjectCreator<Vehicle> {
275 						
276 						@Override
277 						public Vehicle
278 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
279 						{
280 							return 
281 								new
282 								VehicleCompositeImpl 
283 								( 
284 								 new
285 								  VehicleLocalImpl
286 								 ((VehicleLocal
287 								  )localPart
288 								 ), 
289 								 new
290 								  VehicleSharedImpl
291 								 (
292 								 	sharedPart.getId(), sharedPart.getProperties().values()
293 								 ), 
294 								 new
295 								  VehicleStaticImpl
296 								 ((VehicleStatic
297 								  )staticPart
298 								 )
299 								)
300 							;
301 						}
302 					}
303 				
304 				
305 					public static class AliveMessageCreator implements ICompositeWorldObjectCreator<AliveMessage> {
306 						
307 						@Override
308 						public AliveMessage
309 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
310 						{
311 							return 
312 								new
313 								AliveMessageCompositeImpl 
314 								( 
315 								 new
316 								  AliveMessageLocalImpl
317 								 ((AliveMessageLocal
318 								  )localPart
319 								 ), 
320 								 new
321 								  AliveMessageSharedImpl
322 								 (
323 								 	sharedPart.getId(), sharedPart.getProperties().values()
324 								 ), 
325 								 new
326 								  AliveMessageStaticImpl
327 								 ((AliveMessageStatic
328 								  )staticPart
329 								 )
330 								)
331 							;
332 						}
333 					}
334 				
335 				
336 					public static class MyInventoryCreator implements ICompositeWorldObjectCreator<MyInventory> {
337 						
338 						@Override
339 						public MyInventory
340 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
341 						{
342 							return 
343 								new
344 								MyInventoryCompositeImpl 
345 								( 
346 								 new
347 								  MyInventoryLocalImpl
348 								 ((MyInventoryLocal
349 								  )localPart
350 								 ), 
351 								 new
352 								  MyInventorySharedImpl
353 								 (
354 								 	sharedPart.getId(), sharedPart.getProperties().values()
355 								 ), 
356 								 new
357 								  MyInventoryStaticImpl
358 								 ((MyInventoryStatic
359 								  )staticPart
360 								 )
361 								)
362 							;
363 						}
364 					}
365 				
366 				
367 					public static class PlayerCreator implements ICompositeWorldObjectCreator<Player> {
368 						
369 						@Override
370 						public Player
371 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
372 						{
373 							return 
374 								new
375 								PlayerCompositeImpl 
376 								( 
377 								 new
378 								  PlayerLocalImpl
379 								 ((PlayerLocal
380 								  )localPart
381 								 ), 
382 								 new
383 								  PlayerSharedImpl
384 								 (
385 								 	sharedPart.getId(), sharedPart.getProperties().values()
386 								 ), 
387 								 new
388 								  PlayerStaticImpl
389 								 ((PlayerStatic
390 								  )staticPart
391 								 )
392 								)
393 							;
394 						}
395 					}
396 				
397 				
398 					public static class ItemCreator implements ICompositeWorldObjectCreator<Item> {
399 						
400 						@Override
401 						public Item
402 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
403 						{
404 							return 
405 								new
406 								ItemCompositeImpl 
407 								( 
408 								 new
409 								  ItemLocalImpl
410 								 ((ItemLocal
411 								  )localPart
412 								 ), 
413 								 new
414 								  ItemSharedImpl
415 								 (
416 								 	sharedPart.getId(), sharedPart.getProperties().values()
417 								 ), 
418 								 new
419 								  ItemStaticImpl
420 								 ((ItemStatic
421 								  )staticPart
422 								 )
423 								)
424 							;
425 						}
426 					}
427 				
428 				
429 					public static class GameInfoCreator implements ICompositeWorldObjectCreator<GameInfo> {
430 						
431 						@Override
432 						public GameInfo
433 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
434 						{
435 							return 
436 								new
437 								GameInfoCompositeImpl 
438 								( 
439 								 new
440 								  GameInfoLocalImpl
441 								 ((GameInfoLocal
442 								  )localPart
443 								 ), 
444 								 new
445 								  GameInfoSharedImpl
446 								 (
447 								 	sharedPart.getId(), sharedPart.getProperties().values()
448 								 ), 
449 								 new
450 								  GameInfoStaticImpl
451 								 ((GameInfoStatic
452 								  )staticPart
453 								 )
454 								)
455 							;
456 						}
457 					}
458 				
459 				
460 					public static class IncomingProjectileCreator implements ICompositeWorldObjectCreator<IncomingProjectile> {
461 						
462 						@Override
463 						public IncomingProjectile
464 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
465 						{
466 							return 
467 								new
468 								IncomingProjectileCompositeImpl 
469 								( 
470 								 new
471 								  IncomingProjectileLocalImpl
472 								 ((IncomingProjectileLocal
473 								  )localPart
474 								 ), 
475 								 new
476 								  IncomingProjectileSharedImpl
477 								 (
478 								 	sharedPart.getId(), sharedPart.getProperties().values()
479 								 ), 
480 								 new
481 								  IncomingProjectileStaticImpl
482 								 ((IncomingProjectileStatic
483 								  )staticPart
484 								 )
485 								)
486 							;
487 						}
488 					}
489 				
490 				
491 					public static class EntityCreator implements ICompositeWorldObjectCreator<Entity> {
492 						
493 						@Override
494 						public Entity
495 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
496 						{
497 							return 
498 								new
499 								EntityCompositeImpl 
500 								( 
501 								 new
502 								  EntityLocalImpl
503 								 ((EntityLocal
504 								  )localPart
505 								 ), 
506 								 new
507 								  EntitySharedImpl
508 								 (
509 								 	sharedPart.getId(), sharedPart.getProperties().values()
510 								 ), 
511 								 new
512 								  EntityStaticImpl
513 								 ((EntityStatic
514 								  )staticPart
515 								 )
516 								)
517 							;
518 						}
519 					}
520 				
521 				
522 					public static class NavPointCreator implements ICompositeWorldObjectCreator<NavPoint> {
523 						
524 						@Override
525 						public NavPoint
526 							   create(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart) 
527 						{
528 							return 
529 								new
530 								NavPointCompositeImpl 
531 								( 
532 								 new
533 								  NavPointLocalImpl
534 								 ((NavPointLocal
535 								  )localPart
536 								 ), 
537 								 new
538 								  NavPointSharedImpl
539 								 (
540 								 	sharedPart.getId(), sharedPart.getProperties().values()
541 								 ), 
542 								 new
543 								  NavPointStaticImpl
544 								 ((NavPointStatic
545 								  )staticPart
546 								 )
547 								)
548 							;
549 						}
550 					}
551 				
552 				
553 				private static Map<Class, ICompositeWorldObjectCreator> creators = new HashMap<Class, ICompositeWorldObjectCreator>();
554 				
555 				static {
556 					
557 						creators.put(
558 							Self
559 							.class, 
560 							new SelfCreator());
561 					
562 						creators.put(
563 							BombInfo
564 							.class, 
565 							new BombInfoCreator());
566 					
567 						creators.put(
568 							FlagInfo
569 							.class, 
570 							new FlagInfoCreator());
571 					
572 						creators.put(
573 							InitedMessage
574 							.class, 
575 							new InitedMessageCreator());
576 					
577 						creators.put(
578 							TeamScore
579 							.class, 
580 							new TeamScoreCreator());
581 					
582 						creators.put(
583 							AutoTraceRay
584 							.class, 
585 							new AutoTraceRayCreator());
586 					
587 						creators.put(
588 							Mover
589 							.class, 
590 							new MoverCreator());
591 					
592 						creators.put(
593 							ConfigChange
594 							.class, 
595 							new ConfigChangeCreator());
596 					
597 						creators.put(
598 							Vehicle
599 							.class, 
600 							new VehicleCreator());
601 					
602 						creators.put(
603 							AliveMessage
604 							.class, 
605 							new AliveMessageCreator());
606 					
607 						creators.put(
608 							MyInventory
609 							.class, 
610 							new MyInventoryCreator());
611 					
612 						creators.put(
613 							Player
614 							.class, 
615 							new PlayerCreator());
616 					
617 						creators.put(
618 							Item
619 							.class, 
620 							new ItemCreator());
621 					
622 						creators.put(
623 							GameInfo
624 							.class, 
625 							new GameInfoCreator());
626 					
627 						creators.put(
628 							IncomingProjectile
629 							.class, 
630 							new IncomingProjectileCreator());
631 					
632 						creators.put(
633 							Entity
634 							.class, 
635 							new EntityCreator());
636 					
637 						creators.put(
638 							NavPoint
639 							.class, 
640 							new NavPointCreator());
641 					
642 				}
643 				
644 				
645 				public static ICompositeWorldObject createObject(ILocalWorldObject localPart, ISharedWorldObject sharedPart, IStaticWorldObject staticPart)
646 				{
647 					NullCheck.check(localPart,  "localPart");
648 					NullCheck.check(sharedPart, "sharedPart");
649 					NullCheck.check(staticPart, "staticPart");
650 					
651 					NullCheck.check(localPart.getCompositeClass(),  "localPart.getCompositeClass()");
652 					NullCheck.check(sharedPart.getCompositeClass(), "sharedPart.getCompositeClass()");
653 					NullCheck.check(staticPart.getCompositeClass(), "staticPart.getCompositeClass()");
654 					
655 					if ( localPart.getCompositeClass() != sharedPart.getCompositeClass() || sharedPart.getCompositeClass() != staticPart.getCompositeClass()) {
656 						throw new PogamutException("CompositeObject cannot be created, because the objectParts belong to different compositeObject classes : "
657 								+ localPart.getCompositeClass() + "," + sharedPart.getCompositeClass() + "," + staticPart.getCompositeClass() , localPart);
658 					}
659 					
660 					ICompositeWorldObjectCreator creator = creators.get(localPart.getCompositeClass());
661 					if (creator == null) {
662 						throw new PogamutException("There is no ICompositeWorldObjectCreator registered for class " + localPart.getCompositeClass(), UT2004CompositeObjectCreator.class);
663 					} 
664 					
665 					return creator.create(localPart, sharedPart, staticPart);
666 				}
667 			}
668