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 org.andromda.core.metafacade.MetafacadeBase;
9   import org.andromda.core.metafacade.ModelValidationMessage;
10  import org.andromda.metafacades.uml.ActionFacade;
11  import org.andromda.metafacades.uml.ActionStateFacade;
12  import org.apache.log4j.Logger;
13  import org.omg.uml.behavioralelements.activitygraphs.ActionState;
14  
15  /**
16   * A state models a situation during which some (usually implicit) invariant condition holds. The
17   * states of protocol state machines are exposed to the users of their context classifiers. A
18   * protocol state represents an exposed stable situation of its context classifier: when an instance
19   * of the classifier is not processing any operation, users of this instance can always know its
20   * state configuration.
21   * MetafacadeLogic for ActionStateFacade
22   *
23   * @see ActionStateFacade
24   */
25  public abstract class ActionStateFacadeLogic
26      extends StateFacadeLogicImpl
27      implements ActionStateFacade
28  {
29      /**
30       * The underlying UML object
31       * @see ActionState
32       */
33      protected ActionState metaObject;
34  
35      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
36       * @param metaObjectIn
37       * @param context
38       */
39      protected ActionStateFacadeLogic(ActionState 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(ActionStateFacadeLogic.class);
49  
50      /**
51       * Gets the context for this metafacade logic instance.
52       * @param context String. Set to ActionStateFacade 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.ActionStateFacade";
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 ActionStateFacade
80       */
81      public boolean isActionStateFacadeMetaType()
82      {
83          return true;
84      }
85  
86      // ------------- associations ------------------
87  
88      private ActionFacade __getEntry1r;
89      private boolean __getEntry1rSet = false;
90  
91      /**
92       * If this action is located on an action state, this will represent that state.
93       * @return (ActionFacade)handleGetEntry()
94       */
95      public final ActionFacade getEntry()
96      {
97          ActionFacade getEntry1r = this.__getEntry1r;
98          if (!this.__getEntry1rSet)
99          {
100             // actionState has no pre constraints
101             Object result = handleGetEntry();
102             MetafacadeBase shieldedResult = this.shieldedElement(result);
103             try
104             {
105                 getEntry1r = (ActionFacade)shieldedResult;
106             }
107             catch (ClassCastException ex)
108             {
109                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
110                 ActionStateFacadeLogic.logger.warn("incorrect metafacade cast for ActionStateFacadeLogic.getEntry ActionFacade " + result + ": " + shieldedResult);
111             }
112             // actionState has no post constraints
113             this.__getEntry1r = getEntry1r;
114             if (isMetafacadePropertyCachingEnabled())
115             {
116                 this.__getEntry1rSet = true;
117             }
118         }
119         return getEntry1r;
120     }
121 
122     /**
123      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
124      * @return Object
125      */
126     protected abstract Object handleGetEntry();
127 
128     /**
129      * @param validationMessages Collection<ModelValidationMessage>
130      * @see StateFacadeLogicImpl#validateInvariants(Collection validationMessages)
131      */
132     @Override
133     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
134     {
135         super.validateInvariants(validationMessages);
136     }
137 }