1 // license-header java merge-point
2 //
3 // Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
4 //
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import java.util.List;
9 import org.andromda.core.metafacade.ModelValidationMessage;
10 import org.andromda.metafacades.uml.EventFacade;
11 import org.andromda.metafacades.uml.StateFacade;
12 import org.apache.log4j.Logger;
13 import org.omg.uml.behavioralelements.statemachines.State;
14
15 /**
16 * Models a situation during which some (usually implicit) invariant condition holds. The states of
17 * protocol state machines are exposed to the users of their context classifiers. A protocol state
18 * represents an exposed stable situation of its context classifier: when an instance of the
19 * classifier is not processing any operation, users of this instance can always know its state
20 * configuration.
21 * MetafacadeLogic for StateFacade
22 *
23 * @see StateFacade
24 */
25 public abstract class StateFacadeLogic
26 extends StateVertexFacadeLogicImpl
27 implements StateFacade
28 {
29 /**
30 * The underlying UML object
31 * @see State
32 */
33 protected State metaObject;
34
35 /** Create Metafacade implementation instance using the MetafacadeFactory from the context
36 * @param metaObjectIn
37 * @param context
38 */
39 protected StateFacadeLogic(State metaObjectIn, String context)
40 {
41 super(metaObjectIn, getContext(context));
42 this.metaObject = metaObjectIn;
43 }
44
45 /**
46 * The logger instance.
47 */
48 private static final Logger logger = Logger.getLogger(StateFacadeLogic.class);
49
50 /**
51 * Gets the context for this metafacade logic instance.
52 * @param context String. Set to StateFacade if null
53 * @return context String
54 */
55 private static String getContext(String context)
56 {
57 if (context == null)
58 {
59 context = "org.andromda.metafacades.uml.StateFacade";
60 }
61 return context;
62 }
63
64 /** Reset context only for non-root metafacades
65 * @param context
66 */
67 @Override
68 public void resetMetafacadeContext(String context)
69 {
70 if (!this.contextRoot) // reset context only for non-root metafacades
71 {
72 context = getContext(context); // to have same value as in original constructor call
73 setMetafacadeContext (context);
74 }
75 }
76
77 /**
78 * @return boolean true always
79 * @see StateFacade
80 */
81 public boolean isStateFacadeMetaType()
82 {
83 return true;
84 }
85
86 // ------------- associations ------------------
87
88 /**
89 * If this event is located on an action state, this will represent that state.
90 * @return (Collection<EventFacade>)handleGetDeferrableEvents()
91 */
92 public final Collection<EventFacade> getDeferrableEvents()
93 {
94 Collection<EventFacade> getDeferrableEvents1r = null;
95 // state has no pre constraints
96 Collection result = handleGetDeferrableEvents();
97 List shieldedResult = this.shieldedElements(result);
98 try
99 {
100 getDeferrableEvents1r = (Collection<EventFacade>)shieldedResult;
101 }
102 catch (ClassCastException ex)
103 {
104 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
105 StateFacadeLogic.logger.warn("incorrect metafacade cast for StateFacadeLogic.getDeferrableEvents Collection<EventFacade> " + result + ": " + shieldedResult);
106 }
107 // state has no post constraints
108 return getDeferrableEvents1r;
109 }
110
111 /**
112 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
113 * @return Collection
114 */
115 protected abstract Collection handleGetDeferrableEvents();
116
117 /**
118 * @param validationMessages Collection<ModelValidationMessage>
119 * @see StateVertexFacadeLogicImpl#validateInvariants(Collection validationMessages)
120 */
121 @Override
122 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
123 {
124 super.validateInvariants(validationMessages);
125 }
126 }