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.GeneralizableElementFacade;
12  import org.andromda.metafacades.uml.GeneralizationFacade;
13  import org.apache.log4j.Logger;
14  import org.omg.uml.foundation.core.GeneralizableElement;
15  
16  /**
17   * The model element that represents an element that can be generalized or specialized.
18   * MetafacadeLogic for GeneralizableElementFacade
19   *
20   * @see GeneralizableElementFacade
21   */
22  public abstract class GeneralizableElementFacadeLogic
23      extends ModelElementFacadeLogicImpl
24      implements GeneralizableElementFacade
25  {
26      /**
27       * The underlying UML object
28       * @see GeneralizableElement
29       */
30      protected GeneralizableElement metaObject;
31  
32      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
33       * @param metaObjectIn
34       * @param context
35       */
36      protected GeneralizableElementFacadeLogic(GeneralizableElement metaObjectIn, String context)
37      {
38          super(metaObjectIn, getContext(context));
39          this.metaObject = metaObjectIn;
40      }
41  
42      /**
43       * The logger instance.
44       */
45      private static final Logger logger = Logger.getLogger(GeneralizableElementFacadeLogic.class);
46  
47      /**
48       * Gets the context for this metafacade logic instance.
49       * @param context String. Set to GeneralizableElementFacade if null
50       * @return context String
51       */
52      private static String getContext(String context)
53      {
54          if (context == null)
55          {
56              context = "org.andromda.metafacades.uml.GeneralizableElementFacade";
57          }
58          return context;
59      }
60  
61      /** Reset context only for non-root metafacades
62       * @param context
63       */
64      @Override
65      public void resetMetafacadeContext(String context)
66      {
67          if (!this.contextRoot) // reset context only for non-root metafacades
68          {
69              context = getContext(context);  // to have same value as in original constructor call
70              setMetafacadeContext (context);
71          }
72      }
73  
74      /**
75       * @return boolean true always
76       * @see GeneralizableElementFacade
77       */
78      public boolean isGeneralizableElementFacadeMetaType()
79      {
80          return true;
81      }
82  
83      // --------------- attributes ---------------------
84  
85     /**
86      * @see GeneralizableElementFacade#getGeneralizationList()
87      * @return String
88      */
89      protected abstract String handleGetGeneralizationList();
90  
91      private String __generalizationList1a;
92      private boolean __generalizationList1aSet = false;
93  
94      /**
95       * A comma separated list of the fully qualified names of all generalizations.
96       * @return (String)handleGetGeneralizationList()
97       */
98      public final String getGeneralizationList()
99      {
100         String generalizationList1a = this.__generalizationList1a;
101         if (!this.__generalizationList1aSet)
102         {
103             // generalizationList has no pre constraints
104             generalizationList1a = handleGetGeneralizationList();
105             // generalizationList has no post constraints
106             this.__generalizationList1a = generalizationList1a;
107             if (isMetafacadePropertyCachingEnabled())
108             {
109                 this.__generalizationList1aSet = true;
110             }
111         }
112         return generalizationList1a;
113     }
114 
115     // ---------------- business methods ----------------------
116 
117     /**
118      * Method to be implemented in descendants
119      * Finds the tagged value optional searching the entire inheritance hierarchy if 'follow' is set
120      * to true.
121      * @param tagName
122      * @param follow
123      * @return Object
124      */
125     protected abstract Object handleFindTaggedValue(String tagName, boolean follow);
126 
127     /**
128      * Finds the tagged value optional searching the entire inheritance hierarchy if 'follow' is set
129      * to true.
130      * @param tagName String
131      * The name of the tag of the tagged value to find.
132      * @param follow boolean
133      * Whether or not to 'follow' the inheritance hierarchy when searching for the tagged value.
134      * @return handleFindTaggedValue(tagName, follow)
135      */
136     public Object findTaggedValue(String tagName, boolean follow)
137     {
138         // findTaggedValue has no pre constraints
139         Object returnValue = handleFindTaggedValue(tagName, follow);
140         // findTaggedValue has no post constraints
141         return returnValue;
142     }
143 
144     // ------------- associations ------------------
145 
146     /**
147      * The model element that represents an element that can be generalized or specialized.
148      * @return (Collection<GeneralizationFacade>)handleGetGeneralizationLinks()
149      */
150     public final Collection<GeneralizationFacade> getGeneralizationLinks()
151     {
152         Collection<GeneralizationFacade> getGeneralizationLinks1r = null;
153         // generalizableElementFacade has no pre constraints
154         Collection result = handleGetGeneralizationLinks();
155         List shieldedResult = this.shieldedElements(result);
156         try
157         {
158             getGeneralizationLinks1r = (Collection<GeneralizationFacade>)shieldedResult;
159         }
160         catch (ClassCastException ex)
161         {
162             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
163             GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getGeneralizationLinks Collection<GeneralizationFacade> " + result + ": " + shieldedResult);
164         }
165         // generalizableElementFacade has no post constraints
166         return getGeneralizationLinks1r;
167     }
168 
169     /**
170      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
171      * @return  Collection
172      */
173     protected abstract Collection handleGetGeneralizationLinks();
174 
175     /**
176      * The model element that represents an element that can be generalized or specialized.
177      * @return (Collection<GeneralizableElementFacade>)handleGetAllGeneralizations()
178      */
179     public final Collection<GeneralizableElementFacade> getAllGeneralizations()
180     {
181         Collection<GeneralizableElementFacade> getAllGeneralizations2r = null;
182         // generalizableElementFacade has no pre constraints
183         Collection result = handleGetAllGeneralizations();
184         List shieldedResult = this.shieldedElements(result);
185         try
186         {
187             getAllGeneralizations2r = (Collection<GeneralizableElementFacade>)shieldedResult;
188         }
189         catch (ClassCastException ex)
190         {
191             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
192             GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getAllGeneralizations Collection<GeneralizableElementFacade> " + result + ": " + shieldedResult);
193         }
194         // generalizableElementFacade has no post constraints
195         return getAllGeneralizations2r;
196     }
197 
198     /**
199      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
200      * @return  Collection
201      */
202     protected abstract Collection handleGetAllGeneralizations();
203 
204     /**
205      * The model element that represents an element that can be generalized or specialized.
206      * @return (Collection<GeneralizableElementFacade>)handleGetGeneralizations()
207      */
208     public final Collection<GeneralizableElementFacade> getGeneralizations()
209     {
210         Collection<GeneralizableElementFacade> getGeneralizations3r = null;
211         // generalizableElementFacade has no pre constraints
212         Collection result = handleGetGeneralizations();
213         List shieldedResult = this.shieldedElements(result);
214         try
215         {
216             getGeneralizations3r = (Collection<GeneralizableElementFacade>)shieldedResult;
217         }
218         catch (ClassCastException ex)
219         {
220             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
221             GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getGeneralizations Collection<GeneralizableElementFacade> " + result + ": " + shieldedResult);
222         }
223         // generalizableElementFacade has no post constraints
224         return getGeneralizations3r;
225     }
226 
227     /**
228      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
229      * @return  Collection
230      */
231     protected abstract Collection handleGetGeneralizations();
232 
233     private Collection<GeneralizableElementFacade> __getSpecializations4r;
234     private boolean __getSpecializations4rSet = false;
235 
236     /**
237      * The model element that represents an element that can be generalized or specialized.
238      * @return (Collection<GeneralizableElementFacade>)handleGetSpecializations()
239      */
240     public final Collection<GeneralizableElementFacade> getSpecializations()
241     {
242         Collection<GeneralizableElementFacade> getSpecializations4r = this.__getSpecializations4r;
243         if (!this.__getSpecializations4rSet)
244         {
245             // generalizableElementFacade has no pre constraints
246             Collection result = handleGetSpecializations();
247             List shieldedResult = this.shieldedElements(result);
248             try
249             {
250                 getSpecializations4r = (Collection<GeneralizableElementFacade>)shieldedResult;
251             }
252             catch (ClassCastException ex)
253             {
254                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
255                 GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getSpecializations Collection<GeneralizableElementFacade> " + result + ": " + shieldedResult);
256             }
257             // generalizableElementFacade has no post constraints
258             this.__getSpecializations4r = getSpecializations4r;
259             if (isMetafacadePropertyCachingEnabled())
260             {
261                 this.__getSpecializations4rSet = true;
262             }
263         }
264         return getSpecializations4r;
265     }
266 
267     /**
268      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
269      * @return  Collection
270      */
271     protected abstract Collection handleGetSpecializations();
272 
273     /**
274      * The model element that represents an element that can be generalized or specialized.
275      * @return (Collection<GeneralizableElementFacade>)handleGetAllSpecializations()
276      */
277     public final Collection<GeneralizableElementFacade> getAllSpecializations()
278     {
279         Collection<GeneralizableElementFacade> getAllSpecializations5r = null;
280         // generalizableElementFacade has no pre constraints
281         Collection result = handleGetAllSpecializations();
282         List shieldedResult = this.shieldedElements(result);
283         try
284         {
285             getAllSpecializations5r = (Collection<GeneralizableElementFacade>)shieldedResult;
286         }
287         catch (ClassCastException ex)
288         {
289             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
290             GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getAllSpecializations Collection<GeneralizableElementFacade> " + result + ": " + shieldedResult);
291         }
292         // generalizableElementFacade has no post constraints
293         return getAllSpecializations5r;
294     }
295 
296     /**
297      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
298      * @return  Collection
299      */
300     protected abstract Collection handleGetAllSpecializations();
301 
302     /**
303      * The model element that represents an element that can be generalized or specialized.
304      * @return (GeneralizableElementFacade)handleGetGeneralization()
305      */
306     public final GeneralizableElementFacade getGeneralization()
307     {
308         GeneralizableElementFacade getGeneralization6r = null;
309         // generalizableElementFacade has no pre constraints
310         Object result = handleGetGeneralization();
311         MetafacadeBase shieldedResult = this.shieldedElement(result);
312         try
313         {
314             getGeneralization6r = (GeneralizableElementFacade)shieldedResult;
315         }
316         catch (ClassCastException ex)
317         {
318             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
319             GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getGeneralization GeneralizableElementFacade " + result + ": " + shieldedResult);
320         }
321         // generalizableElementFacade has no post constraints
322         return getGeneralization6r;
323     }
324 
325     /**
326      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
327      * @return Object
328      */
329     protected abstract Object handleGetGeneralization();
330 
331     private GeneralizableElementFacade __getGeneralizationRoot7r;
332     private boolean __getGeneralizationRoot7rSet = false;
333 
334     /**
335      * The model element that represents an element that can be generalized or specialized.
336      * @return (GeneralizableElementFacade)handleGetGeneralizationRoot()
337      */
338     public final GeneralizableElementFacade getGeneralizationRoot()
339     {
340         GeneralizableElementFacade getGeneralizationRoot7r = this.__getGeneralizationRoot7r;
341         if (!this.__getGeneralizationRoot7rSet)
342         {
343             // generalizableElementFacade has no pre constraints
344             Object result = handleGetGeneralizationRoot();
345             MetafacadeBase shieldedResult = this.shieldedElement(result);
346             try
347             {
348                 getGeneralizationRoot7r = (GeneralizableElementFacade)shieldedResult;
349             }
350             catch (ClassCastException ex)
351             {
352                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
353                 GeneralizableElementFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizableElementFacadeLogic.getGeneralizationRoot GeneralizableElementFacade " + result + ": " + shieldedResult);
354             }
355             // generalizableElementFacade has no post constraints
356             this.__getGeneralizationRoot7r = getGeneralizationRoot7r;
357             if (isMetafacadePropertyCachingEnabled())
358             {
359                 this.__getGeneralizationRoot7rSet = true;
360             }
361         }
362         return getGeneralizationRoot7r;
363     }
364 
365     /**
366      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
367      * @return Object
368      */
369     protected abstract Object handleGetGeneralizationRoot();
370 
371     /**
372      * @param validationMessages Collection<ModelValidationMessage>
373      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
374      */
375     @Override
376     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
377     {
378         super.validateInvariants(validationMessages);
379     }
380 }