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.ExtendFacade;
12  import org.andromda.metafacades.uml.ExtensionPointFacade;
13  import org.andromda.metafacades.uml.UseCaseFacade;
14  import org.apache.log4j.Logger;
15  import org.omg.uml.behavioralelements.usecases.Extend;
16  
17  /**
18   * A relationship from an extending use case to an extended use case that specifies how and when the
19   * behavior defined in the extending use case can be inserted into the behavior defined in the
20   * extended use case.
21   * MetafacadeLogic for ExtendFacade
22   *
23   * @see ExtendFacade
24   */
25  public abstract class ExtendFacadeLogic
26      extends ModelElementFacadeLogicImpl
27      implements ExtendFacade
28  {
29      /**
30       * The underlying UML object
31       * @see Extend
32       */
33      protected Extend metaObject;
34  
35      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
36       * @param metaObjectIn
37       * @param context
38       */
39      protected ExtendFacadeLogic(Extend 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(ExtendFacadeLogic.class);
49  
50      /**
51       * Gets the context for this metafacade logic instance.
52       * @param context String. Set to ExtendFacade 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.ExtendFacade";
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 ExtendFacade
80       */
81      public boolean isExtendFacadeMetaType()
82      {
83          return true;
84      }
85  
86      // ------------- associations ------------------
87  
88      private List<ExtensionPointFacade> __getExtensionPoints1r;
89      private boolean __getExtensionPoints1rSet = false;
90  
91      /**
92       * A relationship from an extending use case to an extended use case that specifies how and when
93       * the
94       * behavior defined in the extending use case can be inserted into the behavior defined in the
95       * extended
96       * use case.
97       * @return (List<ExtensionPointFacade>)handleGetExtensionPoints()
98       */
99      public final List<ExtensionPointFacade> getExtensionPoints()
100     {
101         List<ExtensionPointFacade> getExtensionPoints1r = this.__getExtensionPoints1r;
102         if (!this.__getExtensionPoints1rSet)
103         {
104             // extendFacade has no pre constraints
105             List result = handleGetExtensionPoints();
106             List shieldedResult = this.shieldedElements(result);
107             try
108             {
109                 getExtensionPoints1r = (List<ExtensionPointFacade>)shieldedResult;
110             }
111             catch (ClassCastException ex)
112             {
113                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
114                 ExtendFacadeLogic.logger.warn("incorrect metafacade cast for ExtendFacadeLogic.getExtensionPoints List<ExtensionPointFacade> " + result + ": " + shieldedResult);
115             }
116             // extendFacade has no post constraints
117             this.__getExtensionPoints1r = getExtensionPoints1r;
118             if (isMetafacadePropertyCachingEnabled())
119             {
120                 this.__getExtensionPoints1rSet = true;
121             }
122         }
123         return getExtensionPoints1r;
124     }
125 
126     /**
127      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
128      * @return  List
129      */
130     protected abstract List handleGetExtensionPoints();
131 
132     private UseCaseFacade __getBase2r;
133     private boolean __getBase2rSet = false;
134 
135     /**
136      * The extend instances related to this use-case.
137      * @return (UseCaseFacade)handleGetBase()
138      */
139     public final UseCaseFacade getBase()
140     {
141         UseCaseFacade getBase2r = this.__getBase2r;
142         if (!this.__getBase2rSet)
143         {
144             // extends has no pre constraints
145             Object result = handleGetBase();
146             MetafacadeBase shieldedResult = this.shieldedElement(result);
147             try
148             {
149                 getBase2r = (UseCaseFacade)shieldedResult;
150             }
151             catch (ClassCastException ex)
152             {
153                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
154                 ExtendFacadeLogic.logger.warn("incorrect metafacade cast for ExtendFacadeLogic.getBase UseCaseFacade " + result + ": " + shieldedResult);
155             }
156             // extends has no post constraints
157             this.__getBase2r = getBase2r;
158             if (isMetafacadePropertyCachingEnabled())
159             {
160                 this.__getBase2rSet = true;
161             }
162         }
163         return getBase2r;
164     }
165 
166     /**
167      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
168      * @return Object
169      */
170     protected abstract Object handleGetBase();
171 
172     private UseCaseFacade __getExtension3r;
173     private boolean __getExtension3rSet = false;
174 
175     /**
176      * A relationship from an extending use case to an extended use case that specifies how and when
177      * the
178      * behavior defined in the extending use case can be inserted into the behavior defined in the
179      * extended
180      * use case.
181      * @return (UseCaseFacade)handleGetExtension()
182      */
183     public final UseCaseFacade getExtension()
184     {
185         UseCaseFacade getExtension3r = this.__getExtension3r;
186         if (!this.__getExtension3rSet)
187         {
188             // extendFacade has no pre constraints
189             Object result = handleGetExtension();
190             MetafacadeBase shieldedResult = this.shieldedElement(result);
191             try
192             {
193                 getExtension3r = (UseCaseFacade)shieldedResult;
194             }
195             catch (ClassCastException ex)
196             {
197                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
198                 ExtendFacadeLogic.logger.warn("incorrect metafacade cast for ExtendFacadeLogic.getExtension UseCaseFacade " + result + ": " + shieldedResult);
199             }
200             // extendFacade has no post constraints
201             this.__getExtension3r = getExtension3r;
202             if (isMetafacadePropertyCachingEnabled())
203             {
204                 this.__getExtension3rSet = true;
205             }
206         }
207         return getExtension3r;
208     }
209 
210     /**
211      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
212      * @return Object
213      */
214     protected abstract Object handleGetExtension();
215 
216     /**
217      * @param validationMessages Collection<ModelValidationMessage>
218      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
219      */
220     @Override
221     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
222     {
223         super.validateInvariants(validationMessages);
224     }
225 }