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.AssociationEndFacade;
12  import org.andromda.metafacades.uml.AssociationFacade;
13  import org.apache.log4j.Logger;
14  import org.omg.uml.foundation.core.UmlAssociation;
15  
16  /**
17   * An association describes a set of tuples whose values refer to typed instances. An instance of an
18   * association is called a link.
19   * MetafacadeLogic for AssociationFacade
20   *
21   * @see AssociationFacade
22   */
23  public abstract class AssociationFacadeLogic
24      extends GeneralizableElementFacadeLogicImpl
25      implements AssociationFacade
26  {
27      /**
28       * The underlying UML object
29       * @see UmlAssociation
30       */
31      protected UmlAssociation metaObject;
32  
33      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
34       * @param metaObjectIn
35       * @param context
36       */
37      protected AssociationFacadeLogic(UmlAssociation metaObjectIn, String context)
38      {
39          super(metaObjectIn, getContext(context));
40          this.metaObject = metaObjectIn;
41      }
42  
43      /**
44       * The logger instance.
45       */
46      private static final Logger logger = Logger.getLogger(AssociationFacadeLogic.class);
47  
48      /**
49       * Gets the context for this metafacade logic instance.
50       * @param context String. Set to AssociationFacade if null
51       * @return context String
52       */
53      private static String getContext(String context)
54      {
55          if (context == null)
56          {
57              context = "org.andromda.metafacades.uml.AssociationFacade";
58          }
59          return context;
60      }
61  
62      /** Reset context only for non-root metafacades
63       * @param context
64       */
65      @Override
66      public void resetMetafacadeContext(String context)
67      {
68          if (!this.contextRoot) // reset context only for non-root metafacades
69          {
70              context = getContext(context);  // to have same value as in original constructor call
71              setMetafacadeContext (context);
72          }
73      }
74  
75      /**
76       * @return boolean true always
77       * @see AssociationFacade
78       */
79      public boolean isAssociationFacadeMetaType()
80      {
81          return true;
82      }
83  
84      // --------------- attributes ---------------------
85  
86     /**
87      * @see AssociationFacade#getRelationName()
88      * @return String
89      */
90      protected abstract String handleGetRelationName();
91  
92      private String __relationName1a;
93      private boolean __relationName1aSet = false;
94  
95      /**
96       * A name suited for naming this relationship. This name will be constructed from both
97       * association ends.
98       * @return (String)handleGetRelationName()
99       */
100     public final String getRelationName()
101     {
102         String relationName1a = this.__relationName1a;
103         if (!this.__relationName1aSet)
104         {
105             // relationName has no pre constraints
106             relationName1a = handleGetRelationName();
107             // relationName has no post constraints
108             this.__relationName1a = relationName1a;
109             if (isMetafacadePropertyCachingEnabled())
110             {
111                 this.__relationName1aSet = true;
112             }
113         }
114         return relationName1a;
115     }
116 
117    /**
118     * @see AssociationFacade#isMany2Many()
119     * @return boolean
120     */
121     protected abstract boolean handleIsMany2Many();
122 
123     private boolean __many2Many2a;
124     private boolean __many2Many2aSet = false;
125 
126     /**
127      * Indicates whether or not this associations represents a many-to-many relation.
128      * @return (boolean)handleIsMany2Many()
129      */
130     public final boolean isMany2Many()
131     {
132         boolean many2Many2a = this.__many2Many2a;
133         if (!this.__many2Many2aSet)
134         {
135             // many2Many has no pre constraints
136             many2Many2a = handleIsMany2Many();
137             // many2Many has no post constraints
138             this.__many2Many2a = many2Many2a;
139             if (isMetafacadePropertyCachingEnabled())
140             {
141                 this.__many2Many2aSet = true;
142             }
143         }
144         return many2Many2a;
145     }
146 
147    /**
148     * @see AssociationFacade#isAssociationClass()
149     * @return boolean
150     */
151     protected abstract boolean handleIsAssociationClass();
152 
153     private boolean __associationClass3a;
154     private boolean __associationClass3aSet = false;
155 
156     /**
157      * True if the AssociationFacade is an AssociationClass.
158      * @return (boolean)handleIsAssociationClass()
159      */
160     public final boolean isAssociationClass()
161     {
162         boolean associationClass3a = this.__associationClass3a;
163         if (!this.__associationClass3aSet)
164         {
165             // associationClass has no pre constraints
166             associationClass3a = handleIsAssociationClass();
167             // associationClass has no post constraints
168             this.__associationClass3a = associationClass3a;
169             if (isMetafacadePropertyCachingEnabled())
170             {
171                 this.__associationClass3aSet = true;
172             }
173         }
174         return associationClass3a;
175     }
176 
177    /**
178     * @see AssociationFacade#isAbstract()
179     * @return boolean
180     */
181     protected abstract boolean handleIsAbstract();
182 
183     private boolean __abstract4a;
184     private boolean __abstract4aSet = false;
185 
186     /**
187      * Indicates if this association is 'abstract'.
188      * @return (boolean)handleIsAbstract()
189      */
190     public final boolean isAbstract()
191     {
192         boolean abstract4a = this.__abstract4a;
193         if (!this.__abstract4aSet)
194         {
195             // abstract has no pre constraints
196             abstract4a = handleIsAbstract();
197             // abstract has no post constraints
198             this.__abstract4a = abstract4a;
199             if (isMetafacadePropertyCachingEnabled())
200             {
201                 this.__abstract4aSet = true;
202             }
203         }
204         return abstract4a;
205     }
206 
207    /**
208     * @see AssociationFacade#isLeaf()
209     * @return boolean
210     */
211     protected abstract boolean handleIsLeaf();
212 
213     private boolean __leaf5a;
214     private boolean __leaf5aSet = false;
215 
216     /**
217      * True if this association cannot be extended and represent a leaf in the inheritance tree.
218      * @return (boolean)handleIsLeaf()
219      */
220     public final boolean isLeaf()
221     {
222         boolean leaf5a = this.__leaf5a;
223         if (!this.__leaf5aSet)
224         {
225             // leaf has no pre constraints
226             leaf5a = handleIsLeaf();
227             // leaf has no post constraints
228             this.__leaf5a = leaf5a;
229             if (isMetafacadePropertyCachingEnabled())
230             {
231                 this.__leaf5aSet = true;
232             }
233         }
234         return leaf5a;
235     }
236 
237    /**
238     * @see AssociationFacade#isDerived()
239     * @return boolean
240     */
241     protected abstract boolean handleIsDerived();
242 
243     private boolean __derived6a;
244     private boolean __derived6aSet = false;
245 
246     /**
247      * UML2: Returns the value of the 'Is Derived' attribute. The default value is "false". If
248      * isDerived is true, the value of the attribute is derived from information elsewhere.
249      * Specifies whether the Property is derived, i.e., whether its value or values can be computed
250      * from other information.
251      * @return (boolean)handleIsDerived()
252      */
253     public final boolean isDerived()
254     {
255         boolean derived6a = this.__derived6a;
256         if (!this.__derived6aSet)
257         {
258             // derived has no pre constraints
259             derived6a = handleIsDerived();
260             // derived has no post constraints
261             this.__derived6a = derived6a;
262             if (isMetafacadePropertyCachingEnabled())
263             {
264                 this.__derived6aSet = true;
265             }
266         }
267         return derived6a;
268     }
269 
270    /**
271     * @see AssociationFacade#isBinary()
272     * @return boolean
273     */
274     protected abstract boolean handleIsBinary();
275 
276     private boolean __binary7a;
277     private boolean __binary7aSet = false;
278 
279     /**
280      * UML2: Determines whether this association is a binary association, i.e. whether it has
281      * exactly two member ends. UML2 allows association classes in the association itself (many2many
282      * with association attributes). Default=true: only two member ends.
283      * @return (boolean)handleIsBinary()
284      */
285     public final boolean isBinary()
286     {
287         boolean binary7a = this.__binary7a;
288         if (!this.__binary7aSet)
289         {
290             // binary has no pre constraints
291             binary7a = handleIsBinary();
292             // binary has no post constraints
293             this.__binary7a = binary7a;
294             if (isMetafacadePropertyCachingEnabled())
295             {
296                 this.__binary7aSet = true;
297             }
298         }
299         return binary7a;
300     }
301 
302     // ------------- associations ------------------
303 
304     /**
305      * The association owning this association end.
306      * @return (List<AssociationEndFacade>)handleGetAssociationEnds()
307      */
308     public final List<AssociationEndFacade> getAssociationEnds()
309     {
310         List<AssociationEndFacade> getAssociationEnds1r = null;
311         // association has no pre constraints
312         List result = handleGetAssociationEnds();
313         List shieldedResult = this.shieldedElements(result);
314         try
315         {
316             getAssociationEnds1r = (List<AssociationEndFacade>)shieldedResult;
317         }
318         catch (ClassCastException ex)
319         {
320             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
321             AssociationFacadeLogic.logger.warn("incorrect metafacade cast for AssociationFacadeLogic.getAssociationEnds List<AssociationEndFacade> " + result + ": " + shieldedResult);
322         }
323         // association has no post constraints
324         return getAssociationEnds1r;
325     }
326 
327     /**
328      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
329      * @return  List
330      */
331     protected abstract List handleGetAssociationEnds();
332 
333     private AssociationEndFacade __getAssociationEndA2r;
334     private boolean __getAssociationEndA2rSet = false;
335 
336     /**
337      * An association describes a set of tuples whose values refer to typed instances. An instance
338      * of an
339      * association is called a link.
340      * @return (AssociationEndFacade)handleGetAssociationEndA()
341      */
342     public final AssociationEndFacade getAssociationEndA()
343     {
344         AssociationEndFacade getAssociationEndA2r = this.__getAssociationEndA2r;
345         if (!this.__getAssociationEndA2rSet)
346         {
347             // associationFacade has no pre constraints
348             Object result = handleGetAssociationEndA();
349             MetafacadeBase shieldedResult = this.shieldedElement(result);
350             try
351             {
352                 getAssociationEndA2r = (AssociationEndFacade)shieldedResult;
353             }
354             catch (ClassCastException ex)
355             {
356                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
357                 AssociationFacadeLogic.logger.warn("incorrect metafacade cast for AssociationFacadeLogic.getAssociationEndA AssociationEndFacade " + result + ": " + shieldedResult);
358             }
359             // associationFacade has no post constraints
360             this.__getAssociationEndA2r = getAssociationEndA2r;
361             if (isMetafacadePropertyCachingEnabled())
362             {
363                 this.__getAssociationEndA2rSet = true;
364             }
365         }
366         return getAssociationEndA2r;
367     }
368 
369     /**
370      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
371      * @return Object
372      */
373     protected abstract Object handleGetAssociationEndA();
374 
375     private AssociationEndFacade __getAssociationEndB3r;
376     private boolean __getAssociationEndB3rSet = false;
377 
378     /**
379      * An association describes a set of tuples whose values refer to typed instances. An instance
380      * of an
381      * association is called a link.
382      * @return (AssociationEndFacade)handleGetAssociationEndB()
383      */
384     public final AssociationEndFacade getAssociationEndB()
385     {
386         AssociationEndFacade getAssociationEndB3r = this.__getAssociationEndB3r;
387         if (!this.__getAssociationEndB3rSet)
388         {
389             // associationFacade has no pre constraints
390             Object result = handleGetAssociationEndB();
391             MetafacadeBase shieldedResult = this.shieldedElement(result);
392             try
393             {
394                 getAssociationEndB3r = (AssociationEndFacade)shieldedResult;
395             }
396             catch (ClassCastException ex)
397             {
398                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
399                 AssociationFacadeLogic.logger.warn("incorrect metafacade cast for AssociationFacadeLogic.getAssociationEndB AssociationEndFacade " + result + ": " + shieldedResult);
400             }
401             // associationFacade has no post constraints
402             this.__getAssociationEndB3r = getAssociationEndB3r;
403             if (isMetafacadePropertyCachingEnabled())
404             {
405                 this.__getAssociationEndB3rSet = true;
406             }
407         }
408         return getAssociationEndB3r;
409     }
410 
411     /**
412      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
413      * @return Object
414      */
415     protected abstract Object handleGetAssociationEndB();
416 
417     /**
418      * @param validationMessages Collection<ModelValidationMessage>
419      * @see GeneralizableElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
420      */
421     @Override
422     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
423     {
424         super.validateInvariants(validationMessages);
425     }
426 }