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.EventFacade;
12  import org.andromda.metafacades.uml.ParameterFacade;
13  import org.andromda.metafacades.uml.StateFacade;
14  import org.andromda.metafacades.uml.TransitionFacade;
15  import org.apache.log4j.Logger;
16  import org.omg.uml.behavioralelements.statemachines.Event;
17  
18  /**
19   * A representation of the model object 'Activity'. The specification of parameterized behavior as
20   * the coordinated sequencing of subordinate units whose individual elements are actions.
21   * MetafacadeLogic for EventFacade
22   *
23   * @see EventFacade
24   */
25  public abstract class EventFacadeLogic
26      extends ModelElementFacadeLogicImpl
27      implements EventFacade
28  {
29      /**
30       * The underlying UML object
31       * @see Event
32       */
33      protected Event metaObject;
34  
35      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
36       * @param metaObjectIn
37       * @param context
38       */
39      protected EventFacadeLogic(Event 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(EventFacadeLogic.class);
49  
50      /**
51       * Gets the context for this metafacade logic instance.
52       * @param context String. Set to EventFacade 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.EventFacade";
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 EventFacade
80       */
81      public boolean isEventFacadeMetaType()
82      {
83          return true;
84      }
85  
86      // ------------- associations ------------------
87  
88      /**
89       * If this parameter is located on an event, this will represent that event.
90       * @return (Collection<ParameterFacade>)handleGetParameters()
91       */
92      public final Collection<ParameterFacade> getParameters()
93      {
94          Collection<ParameterFacade> getParameters1r = null;
95          // event has no pre constraints
96          Collection result = handleGetParameters();
97          List shieldedResult = this.shieldedElements(result);
98          try
99          {
100             getParameters1r = (Collection<ParameterFacade>)shieldedResult;
101         }
102         catch (ClassCastException ex)
103         {
104             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
105             EventFacadeLogic.logger.warn("incorrect metafacade cast for EventFacadeLogic.getParameters Collection<ParameterFacade> " + result + ": " + shieldedResult);
106         }
107         // event has no post constraints
108         return getParameters1r;
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 handleGetParameters();
116 
117     /**
118      * If a trigger is present on this transition, this event represents that trigger.
119      * @return (TransitionFacade)handleGetTransition()
120      */
121     public final TransitionFacade getTransition()
122     {
123         TransitionFacade getTransition2r = null;
124         // trigger has no pre constraints
125         Object result = handleGetTransition();
126         MetafacadeBase shieldedResult = this.shieldedElement(result);
127         try
128         {
129             getTransition2r = (TransitionFacade)shieldedResult;
130         }
131         catch (ClassCastException ex)
132         {
133             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
134             EventFacadeLogic.logger.warn("incorrect metafacade cast for EventFacadeLogic.getTransition TransitionFacade " + result + ": " + shieldedResult);
135         }
136         // trigger has no post constraints
137         return getTransition2r;
138     }
139 
140     /**
141      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
142      * @return Object
143      */
144     protected abstract Object handleGetTransition();
145 
146     /**
147      * Events to which is being deferred in this action state.
148      * @return (StateFacade)handleGetState()
149      */
150     public final StateFacade getState()
151     {
152         StateFacade getState3r = null;
153         // deferrableEvents has no pre constraints
154         Object result = handleGetState();
155         MetafacadeBase shieldedResult = this.shieldedElement(result);
156         try
157         {
158             getState3r = (StateFacade)shieldedResult;
159         }
160         catch (ClassCastException ex)
161         {
162             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
163             EventFacadeLogic.logger.warn("incorrect metafacade cast for EventFacadeLogic.getState StateFacade " + result + ": " + shieldedResult);
164         }
165         // deferrableEvents has no post constraints
166         return getState3r;
167     }
168 
169     /**
170      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
171      * @return Object
172      */
173     protected abstract Object handleGetState();
174 
175     /**
176      * @param validationMessages Collection<ModelValidationMessage>
177      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
178      */
179     @Override
180     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
181     {
182         super.validateInvariants(validationMessages);
183     }
184 }