View Javadoc
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.MetafacadeBase;
10  import org.andromda.core.metafacade.ModelValidationMessage;
11  import org.andromda.metafacades.uml.FinalStateFacade;
12  import org.andromda.metafacades.uml.ModelElementFacade;
13  import org.andromda.metafacades.uml.PseudostateFacade;
14  import org.andromda.metafacades.uml.StateFacade;
15  import org.andromda.metafacades.uml.StateMachineFacade;
16  import org.andromda.metafacades.uml.TransitionFacade;
17  import org.apache.log4j.Logger;
18  import org.omg.uml.behavioralelements.statemachines.StateMachine;
19  
20  /**
21   * State machines can be used to express the behavior of part of a system. Behavior is modeled as a
22   * traversal of a graph of state nodes interconnected by one or more joined transition arcs that are
23   * triggered by the dispatching of series of (event) occurrences. During this traversal, the state
24   * machine executes a series of activities associated with various elements of the state machine.
25   * MetafacadeLogic for StateMachineFacade
26   *
27   * @see StateMachineFacade
28   */
29  public abstract class StateMachineFacadeLogic
30      extends ModelElementFacadeLogicImpl
31      implements StateMachineFacade
32  {
33      /**
34       * The underlying UML object
35       * @see StateMachine
36       */
37      protected StateMachine metaObject;
38  
39      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
40       * @param metaObjectIn
41       * @param context
42       */
43      protected StateMachineFacadeLogic(StateMachine metaObjectIn, String context)
44      {
45          super(metaObjectIn, getContext(context));
46          this.metaObject = metaObjectIn;
47      }
48  
49      /**
50       * The logger instance.
51       */
52      private static final Logger logger = Logger.getLogger(StateMachineFacadeLogic.class);
53  
54      /**
55       * Gets the context for this metafacade logic instance.
56       * @param context String. Set to StateMachineFacade if null
57       * @return context String
58       */
59      private static String getContext(String context)
60      {
61          if (context == null)
62          {
63              context = "org.andromda.metafacades.uml.StateMachineFacade";
64          }
65          return context;
66      }
67  
68      /** Reset context only for non-root metafacades
69       * @param context
70       */
71      @Override
72      public void resetMetafacadeContext(String context)
73      {
74          if (!this.contextRoot) // reset context only for non-root metafacades
75          {
76              context = getContext(context);  // to have same value as in original constructor call
77              setMetafacadeContext (context);
78          }
79      }
80  
81      /**
82       * @return boolean true always
83       * @see StateMachineFacade
84       */
85      public boolean isStateMachineFacadeMetaType()
86      {
87          return true;
88      }
89  
90      // ------------- associations ------------------
91  
92      private Collection<StateFacade> __getStates1r;
93      private boolean __getStates1rSet = false;
94  
95      /**
96       * State machines can be used to express the behavior of part of a system. Behavior is modeled
97       * as a
98       * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
99       * are
100      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
101      * state
102      * machine executes a series of activities associated with various elements of the state
103      * machine.
104      * @return (Collection<StateFacade>)handleGetStates()
105      */
106     public final Collection<StateFacade> getStates()
107     {
108         Collection<StateFacade> getStates1r = this.__getStates1r;
109         if (!this.__getStates1rSet)
110         {
111             // stateMachineFacade has no pre constraints
112             Collection result = handleGetStates();
113             List shieldedResult = this.shieldedElements(result);
114             try
115             {
116                 getStates1r = (Collection<StateFacade>)shieldedResult;
117             }
118             catch (ClassCastException ex)
119             {
120                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
121                 StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getStates Collection<StateFacade> " + result + ": " + shieldedResult);
122             }
123             // stateMachineFacade has no post constraints
124             this.__getStates1r = getStates1r;
125             if (isMetafacadePropertyCachingEnabled())
126             {
127                 this.__getStates1rSet = true;
128             }
129         }
130         return getStates1r;
131     }
132 
133     /**
134      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
135      * @return  Collection
136      */
137     protected abstract Collection handleGetStates();
138 
139     private PseudostateFacade __getInitialState2r;
140     private boolean __getInitialState2rSet = false;
141 
142     /**
143      * State machines can be used to express the behavior of part of a system. Behavior is modeled
144      * as a
145      * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
146      * are
147      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
148      * state
149      * machine executes a series of activities associated with various elements of the state
150      * machine.
151      * @return (PseudostateFacade)handleGetInitialState()
152      */
153     public final PseudostateFacade getInitialState()
154     {
155         PseudostateFacade getInitialState2r = this.__getInitialState2r;
156         if (!this.__getInitialState2rSet)
157         {
158             // stateMachineFacade has no pre constraints
159             Object result = handleGetInitialState();
160             MetafacadeBase shieldedResult = this.shieldedElement(result);
161             try
162             {
163                 getInitialState2r = (PseudostateFacade)shieldedResult;
164             }
165             catch (ClassCastException ex)
166             {
167                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
168                 StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getInitialState PseudostateFacade " + result + ": " + shieldedResult);
169             }
170             // stateMachineFacade has no post constraints
171             this.__getInitialState2r = getInitialState2r;
172             if (isMetafacadePropertyCachingEnabled())
173             {
174                 this.__getInitialState2rSet = true;
175             }
176         }
177         return getInitialState2r;
178     }
179 
180     /**
181      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
182      * @return Object
183      */
184     protected abstract Object handleGetInitialState();
185 
186     /**
187      * State machines can be used to express the behavior of part of a system. Behavior is modeled
188      * as a
189      * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
190      * are
191      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
192      * state
193      * machine executes a series of activities associated with various elements of the state
194      * machine.
195      * @return (Collection<PseudostateFacade>)handleGetInitialStates()
196      */
197     public final Collection<PseudostateFacade> getInitialStates()
198     {
199         Collection<PseudostateFacade> getInitialStates3r = null;
200         // stateMachineFacade has no pre constraints
201         Collection result = handleGetInitialStates();
202         List shieldedResult = this.shieldedElements(result);
203         try
204         {
205             getInitialStates3r = (Collection<PseudostateFacade>)shieldedResult;
206         }
207         catch (ClassCastException ex)
208         {
209             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
210             StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getInitialStates Collection<PseudostateFacade> " + result + ": " + shieldedResult);
211         }
212         // stateMachineFacade has no post constraints
213         return getInitialStates3r;
214     }
215 
216     /**
217      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
218      * @return  Collection
219      */
220     protected abstract Collection handleGetInitialStates();
221 
222     /**
223      * State machines can be used to express the behavior of part of a system. Behavior is modeled
224      * as a
225      * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
226      * are
227      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
228      * state
229      * machine executes a series of activities associated with various elements of the state
230      * machine.
231      * @return (Collection<PseudostateFacade>)handleGetPseudostates()
232      */
233     public final Collection<PseudostateFacade> getPseudostates()
234     {
235         Collection<PseudostateFacade> getPseudostates4r = null;
236         // stateMachineFacade has no pre constraints
237         Collection result = handleGetPseudostates();
238         List shieldedResult = this.shieldedElements(result);
239         try
240         {
241             getPseudostates4r = (Collection<PseudostateFacade>)shieldedResult;
242         }
243         catch (ClassCastException ex)
244         {
245             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
246             StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getPseudostates Collection<PseudostateFacade> " + result + ": " + shieldedResult);
247         }
248         // stateMachineFacade has no post constraints
249         return getPseudostates4r;
250     }
251 
252     /**
253      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
254      * @return  Collection
255      */
256     protected abstract Collection handleGetPseudostates();
257 
258     /**
259      * State machines can be used to express the behavior of part of a system. Behavior is modeled
260      * as a
261      * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
262      * are
263      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
264      * state
265      * machine executes a series of activities associated with various elements of the state
266      * machine.
267      * @return (Collection<TransitionFacade>)handleGetTransitions()
268      */
269     public final Collection<TransitionFacade> getTransitions()
270     {
271         Collection<TransitionFacade> getTransitions5r = null;
272         // stateMachineFacade has no pre constraints
273         Collection result = handleGetTransitions();
274         List shieldedResult = this.shieldedElements(result);
275         try
276         {
277             getTransitions5r = (Collection<TransitionFacade>)shieldedResult;
278         }
279         catch (ClassCastException ex)
280         {
281             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
282             StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getTransitions Collection<TransitionFacade> " + result + ": " + shieldedResult);
283         }
284         // stateMachineFacade has no post constraints
285         return getTransitions5r;
286     }
287 
288     /**
289      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
290      * @return  Collection
291      */
292     protected abstract Collection handleGetTransitions();
293 
294     private TransitionFacade __getInitialTransition6r;
295     private boolean __getInitialTransition6rSet = false;
296 
297     /**
298      * State machines can be used to express the behavior of part of a system. Behavior is modeled
299      * as a
300      * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
301      * are
302      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
303      * state
304      * machine executes a series of activities associated with various elements of the state
305      * machine.
306      * @return (TransitionFacade)handleGetInitialTransition()
307      */
308     public final TransitionFacade getInitialTransition()
309     {
310         TransitionFacade getInitialTransition6r = this.__getInitialTransition6r;
311         if (!this.__getInitialTransition6rSet)
312         {
313             // stateMachineFacade has no pre constraints
314             Object result = handleGetInitialTransition();
315             MetafacadeBase shieldedResult = this.shieldedElement(result);
316             try
317             {
318                 getInitialTransition6r = (TransitionFacade)shieldedResult;
319             }
320             catch (ClassCastException ex)
321             {
322                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
323                 StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getInitialTransition TransitionFacade " + result + ": " + shieldedResult);
324             }
325             // stateMachineFacade has no post constraints
326             this.__getInitialTransition6r = getInitialTransition6r;
327             if (isMetafacadePropertyCachingEnabled())
328             {
329                 this.__getInitialTransition6rSet = true;
330             }
331         }
332         return getInitialTransition6r;
333     }
334 
335     /**
336      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
337      * @return Object
338      */
339     protected abstract Object handleGetInitialTransition();
340 
341     /**
342      * State machines can be used to express the behavior of part of a system. Behavior is modeled
343      * as a
344      * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
345      * are
346      * triggered by the dispatching of series of (event) occurrences. During this traversal, the
347      * state
348      * machine executes a series of activities associated with various elements of the state
349      * machine.
350      * @return (Collection<FinalStateFacade>)handleGetFinalStates()
351      */
352     public final Collection<FinalStateFacade> getFinalStates()
353     {
354         Collection<FinalStateFacade> getFinalStates7r = null;
355         // stateMachineFacade has no pre constraints
356         Collection result = handleGetFinalStates();
357         List shieldedResult = this.shieldedElements(result);
358         try
359         {
360             getFinalStates7r = (Collection<FinalStateFacade>)shieldedResult;
361         }
362         catch (ClassCastException ex)
363         {
364             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
365             StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getFinalStates Collection<FinalStateFacade> " + result + ": " + shieldedResult);
366         }
367         // stateMachineFacade has no post constraints
368         return getFinalStates7r;
369     }
370 
371     /**
372      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
373      * @return  Collection
374      */
375     protected abstract Collection handleGetFinalStates();
376 
377     /**
378      * If this model element is the context of an activity graph, this represents that activity
379      * graph.
380      * @return (ModelElementFacade)handleGetContextElement()
381      */
382     public final ModelElementFacade getContextElement()
383     {
384         ModelElementFacade getContextElement8r = null;
385         // stateMachineContext has no pre constraints
386         Object result = handleGetContextElement();
387         MetafacadeBase shieldedResult = this.shieldedElement(result);
388         try
389         {
390             getContextElement8r = (ModelElementFacade)shieldedResult;
391         }
392         catch (ClassCastException ex)
393         {
394             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
395             StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getContextElement ModelElementFacade " + result + ": " + shieldedResult);
396         }
397         // stateMachineContext has no post constraints
398         return getContextElement8r;
399     }
400 
401     /**
402      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
403      * @return Object
404      */
405     protected abstract Object handleGetContextElement();
406 
407     /**
408      * @param validationMessages Collection<ModelValidationMessage>
409      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
410      */
411     @Override
412     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
413     {
414         super.validateInvariants(validationMessages);
415     }
416 }