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.InstanceFacade;
13  import org.andromda.metafacades.uml.LinkEndFacade;
14  import org.andromda.metafacades.uml.LinkFacade;
15  import org.apache.log4j.Logger;
16  import org.omg.uml.behavioralelements.commonbehavior.LinkEnd;
17  
18  /**
19   * Can be an AttributeLinkImpl or LinkEndImpl. A representation of the model object 'Slot'. A slot
20   * specifies that an entity modeled by an instance specification has a value or values for a
21   * specific structural feature.
22   * MetafacadeLogic for LinkEndFacade
23   *
24   * @see LinkEndFacade
25   */
26  public abstract class LinkEndFacadeLogic
27      extends ModelElementFacadeLogicImpl
28      implements LinkEndFacade
29  {
30      /**
31       * The underlying UML object
32       * @see LinkEnd
33       */
34      protected LinkEnd metaObject;
35  
36      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
37       * @param metaObjectIn
38       * @param context
39       */
40      protected LinkEndFacadeLogic(LinkEnd metaObjectIn, String context)
41      {
42          super(metaObjectIn, getContext(context));
43          this.metaObject = metaObjectIn;
44      }
45  
46      /**
47       * The logger instance.
48       */
49      private static final Logger logger = Logger.getLogger(LinkEndFacadeLogic.class);
50  
51      /**
52       * Gets the context for this metafacade logic instance.
53       * @param context String. Set to LinkEndFacade if null
54       * @return context String
55       */
56      private static String getContext(String context)
57      {
58          if (context == null)
59          {
60              context = "org.andromda.metafacades.uml.LinkEndFacade";
61          }
62          return context;
63      }
64  
65      /** Reset context only for non-root metafacades
66       * @param context
67       */
68      @Override
69      public void resetMetafacadeContext(String context)
70      {
71          if (!this.contextRoot) // reset context only for non-root metafacades
72          {
73              context = getContext(context);  // to have same value as in original constructor call
74              setMetafacadeContext (context);
75          }
76      }
77  
78      /**
79       * @return boolean true always
80       * @see LinkEndFacade
81       */
82      public boolean isLinkEndFacadeMetaType()
83      {
84          return true;
85      }
86  
87      // ------------- associations ------------------
88  
89      private LinkFacade __getLink1r;
90      private boolean __getLink1rSet = false;
91  
92      /**
93       * The two links ends owned by this link.
94       * @return (LinkFacade)handleGetLink()
95       */
96      public final LinkFacade getLink()
97      {
98          LinkFacade getLink1r = this.__getLink1r;
99          if (!this.__getLink1rSet)
100         {
101             // linkEnds has no pre constraints
102             Object result = handleGetLink();
103             MetafacadeBase shieldedResult = this.shieldedElement(result);
104             try
105             {
106                 getLink1r = (LinkFacade)shieldedResult;
107             }
108             catch (ClassCastException ex)
109             {
110                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
111                 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getLink LinkFacade " + result + ": " + shieldedResult);
112             }
113             // linkEnds has no post constraints
114             this.__getLink1r = getLink1r;
115             if (isMetafacadePropertyCachingEnabled())
116             {
117                 this.__getLink1rSet = true;
118             }
119         }
120         return getLink1r;
121     }
122 
123     /**
124      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
125      * @return Object
126      */
127     protected abstract Object handleGetLink();
128 
129     private AssociationEndFacade __getAssociationEnd2r;
130     private boolean __getAssociationEnd2rSet = false;
131 
132     /**
133      * Can be an AttributeLinkImpl or LinkEndImpl. A representation of the model object 'Slot'. A
134      * slot
135      * specifies that an entity modeled by an instance specification has a value or values for a
136      * specific
137      * structural feature.
138      * @return (AssociationEndFacade)handleGetAssociationEnd()
139      */
140     public final AssociationEndFacade getAssociationEnd()
141     {
142         AssociationEndFacade getAssociationEnd2r = this.__getAssociationEnd2r;
143         if (!this.__getAssociationEnd2rSet)
144         {
145             // linkEndFacade has no pre constraints
146             Object result = handleGetAssociationEnd();
147             MetafacadeBase shieldedResult = this.shieldedElement(result);
148             try
149             {
150                 getAssociationEnd2r = (AssociationEndFacade)shieldedResult;
151             }
152             catch (ClassCastException ex)
153             {
154                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
155                 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getAssociationEnd AssociationEndFacade " + result + ": " + shieldedResult);
156             }
157             // linkEndFacade has no post constraints
158             this.__getAssociationEnd2r = getAssociationEnd2r;
159             if (isMetafacadePropertyCachingEnabled())
160             {
161                 this.__getAssociationEnd2rSet = true;
162             }
163         }
164         return getAssociationEnd2r;
165     }
166 
167     /**
168      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
169      * @return Object
170      */
171     protected abstract Object handleGetAssociationEnd();
172 
173     private InstanceFacade __getInstance3r;
174     private boolean __getInstance3rSet = false;
175 
176     /**
177      * Those slots that map onto association ends.
178      * @return (InstanceFacade)handleGetInstance()
179      */
180     public final InstanceFacade getInstance()
181     {
182         InstanceFacade getInstance3r = this.__getInstance3r;
183         if (!this.__getInstance3rSet)
184         {
185             // linkEnds has no pre constraints
186             Object result = handleGetInstance();
187             MetafacadeBase shieldedResult = this.shieldedElement(result);
188             try
189             {
190                 getInstance3r = (InstanceFacade)shieldedResult;
191             }
192             catch (ClassCastException ex)
193             {
194                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
195                 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getInstance InstanceFacade " + result + ": " + shieldedResult);
196             }
197             // linkEnds has no post constraints
198             this.__getInstance3r = getInstance3r;
199             if (isMetafacadePropertyCachingEnabled())
200             {
201                 this.__getInstance3rSet = true;
202             }
203         }
204         return getInstance3r;
205     }
206 
207     /**
208      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
209      * @return Object
210      */
211     protected abstract Object handleGetInstance();
212 
213     private Collection<InstanceFacade> __getInstances4r;
214     private boolean __getInstances4rSet = false;
215 
216     /**
217      * Can be an AttributeLinkImpl or LinkEndImpl. A representation of the model object 'Slot'. A
218      * slot
219      * specifies that an entity modeled by an instance specification has a value or values for a
220      * specific
221      * structural feature.
222      * @return (Collection<InstanceFacade>)handleGetInstances()
223      */
224     public final Collection<InstanceFacade> getInstances()
225     {
226         Collection<InstanceFacade> getInstances4r = this.__getInstances4r;
227         if (!this.__getInstances4rSet)
228         {
229             // linkEndFacade has no pre constraints
230             Collection result = handleGetInstances();
231             List shieldedResult = this.shieldedElements(result);
232             try
233             {
234                 getInstances4r = (Collection<InstanceFacade>)shieldedResult;
235             }
236             catch (ClassCastException ex)
237             {
238                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
239                 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getInstances Collection<InstanceFacade> " + result + ": " + shieldedResult);
240             }
241             // linkEndFacade has no post constraints
242             this.__getInstances4r = getInstances4r;
243             if (isMetafacadePropertyCachingEnabled())
244             {
245                 this.__getInstances4rSet = true;
246             }
247         }
248         return getInstances4r;
249     }
250 
251     /**
252      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
253      * @return  Collection
254      */
255     protected abstract Collection handleGetInstances();
256 
257     /**
258      * @param validationMessages Collection<ModelValidationMessage>
259      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
260      */
261     @Override
262     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
263     {
264         super.validateInvariants(validationMessages);
265     }
266 }