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.ModelValidationMessage;
10  import org.andromda.metafacades.uml.AttributeLinkFacade;
11  import org.andromda.metafacades.uml.ClassifierFacade;
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.Instance;
17  
18  /**
19   * A representation of the model object 'Instance Specification'. Represents an instance in a
20   * modeled system. Has the capability of being a deployment target in a deployment relationship, in
21   * the case that it is an instance of a node. Has the capability of being a deployed artifact, if it
22   * is an instance of an artifact.
23   * MetafacadeLogic for InstanceFacade
24   *
25   * @see InstanceFacade
26   */
27  public abstract class InstanceFacadeLogic
28      extends ModelElementFacadeLogicImpl
29      implements InstanceFacade
30  {
31      /**
32       * The underlying UML object
33       * @see Instance
34       */
35      protected Instance metaObject;
36  
37      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
38       * @param metaObjectIn
39       * @param context
40       */
41      protected InstanceFacadeLogic(Instance metaObjectIn, String context)
42      {
43          super(metaObjectIn, getContext(context));
44          this.metaObject = metaObjectIn;
45      }
46  
47      /**
48       * The logger instance.
49       */
50      private static final Logger logger = Logger.getLogger(InstanceFacadeLogic.class);
51  
52      /**
53       * Gets the context for this metafacade logic instance.
54       * @param context String. Set to InstanceFacade if null
55       * @return context String
56       */
57      private static String getContext(String context)
58      {
59          if (context == null)
60          {
61              context = "org.andromda.metafacades.uml.InstanceFacade";
62          }
63          return context;
64      }
65  
66      /** Reset context only for non-root metafacades
67       * @param context
68       */
69      @Override
70      public void resetMetafacadeContext(String context)
71      {
72          if (!this.contextRoot) // reset context only for non-root metafacades
73          {
74              context = getContext(context);  // to have same value as in original constructor call
75              setMetafacadeContext (context);
76          }
77      }
78  
79      /**
80       * @return boolean true always
81       * @see InstanceFacade
82       */
83      public boolean isInstanceFacadeMetaType()
84      {
85          return true;
86      }
87  
88      // ------------- associations ------------------
89  
90      private Collection<LinkFacade> __getOwnedLinks1r;
91      private boolean __getOwnedLinks1rSet = false;
92  
93      /**
94       * A representation of the model object 'Instance Specification'. Represents an instance in a
95       * modeled
96       * system. Has the capability of being a deployment target in a deployment relationship, in the
97       * case
98       * that it is an instance of a node. Has the capability of being a deployed artifact, if it is
99       * an
100      * instance of an artifact.
101      * @return (Collection<LinkFacade>)handleGetOwnedLinks()
102      */
103     public final Collection<LinkFacade> getOwnedLinks()
104     {
105         Collection<LinkFacade> getOwnedLinks1r = this.__getOwnedLinks1r;
106         if (!this.__getOwnedLinks1rSet)
107         {
108             // instanceFacade has no pre constraints
109             Collection result = handleGetOwnedLinks();
110             List shieldedResult = this.shieldedElements(result);
111             try
112             {
113                 getOwnedLinks1r = (Collection<LinkFacade>)shieldedResult;
114             }
115             catch (ClassCastException ex)
116             {
117                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
118                 InstanceFacadeLogic.logger.warn("incorrect metafacade cast for InstanceFacadeLogic.getOwnedLinks Collection<LinkFacade> " + result + ": " + shieldedResult);
119             }
120             // instanceFacade has no post constraints
121             this.__getOwnedLinks1r = getOwnedLinks1r;
122             if (isMetafacadePropertyCachingEnabled())
123             {
124                 this.__getOwnedLinks1rSet = true;
125             }
126         }
127         return getOwnedLinks1r;
128     }
129 
130     /**
131      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
132      * @return  Collection
133      */
134     protected abstract Collection handleGetOwnedLinks();
135 
136     private Collection<InstanceFacade> __getOwnedInstances2r;
137     private boolean __getOwnedInstances2rSet = false;
138 
139     /**
140      * A representation of the model object 'Instance Specification'. Represents an instance in a
141      * modeled
142      * system. Has the capability of being a deployment target in a deployment relationship, in the
143      * case
144      * that it is an instance of a node. Has the capability of being a deployed artifact, if it is
145      * an
146      * instance of an artifact.
147      * @return (Collection<InstanceFacade>)handleGetOwnedInstances()
148      */
149     public final Collection<InstanceFacade> getOwnedInstances()
150     {
151         Collection<InstanceFacade> getOwnedInstances2r = this.__getOwnedInstances2r;
152         if (!this.__getOwnedInstances2rSet)
153         {
154             // instanceFacade has no pre constraints
155             Collection result = handleGetOwnedInstances();
156             List shieldedResult = this.shieldedElements(result);
157             try
158             {
159                 getOwnedInstances2r = (Collection<InstanceFacade>)shieldedResult;
160             }
161             catch (ClassCastException ex)
162             {
163                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
164                 InstanceFacadeLogic.logger.warn("incorrect metafacade cast for InstanceFacadeLogic.getOwnedInstances Collection<InstanceFacade> " + result + ": " + shieldedResult);
165             }
166             // instanceFacade has no post constraints
167             this.__getOwnedInstances2r = getOwnedInstances2r;
168             if (isMetafacadePropertyCachingEnabled())
169             {
170                 this.__getOwnedInstances2rSet = true;
171             }
172         }
173         return getOwnedInstances2r;
174     }
175 
176     /**
177      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
178      * @return  Collection
179      */
180     protected abstract Collection handleGetOwnedInstances();
181 
182     /**
183      * The instances this attribute link is attached too. An attribute link can have many instance
184      * values when its defining feature is an attribute with a 'many' multiplicity.
185      * @return (Collection<AttributeLinkFacade>)handleGetSlots()
186      */
187     public final Collection<AttributeLinkFacade> getSlots()
188     {
189         Collection<AttributeLinkFacade> getSlots3r = null;
190         // values has no pre constraints
191         Collection result = handleGetSlots();
192         List shieldedResult = this.shieldedElements(result);
193         try
194         {
195             getSlots3r = (Collection<AttributeLinkFacade>)shieldedResult;
196         }
197         catch (ClassCastException ex)
198         {
199             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
200             InstanceFacadeLogic.logger.warn("incorrect metafacade cast for InstanceFacadeLogic.getSlots Collection<AttributeLinkFacade> " + result + ": " + shieldedResult);
201         }
202         // values has no post constraints
203         return getSlots3r;
204     }
205 
206     /**
207      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
208      * @return  Collection
209      */
210     protected abstract Collection handleGetSlots();
211 
212     private Collection<LinkEndFacade> __getLinkEnds4r;
213     private boolean __getLinkEnds4rSet = false;
214 
215     /**
216      * The first instance to which this link end is attached.
217      * @return (Collection<LinkEndFacade>)handleGetLinkEnds()
218      */
219     public final Collection<LinkEndFacade> getLinkEnds()
220     {
221         Collection<LinkEndFacade> getLinkEnds4r = this.__getLinkEnds4r;
222         if (!this.__getLinkEnds4rSet)
223         {
224             // instance has no pre constraints
225             Collection result = handleGetLinkEnds();
226             List shieldedResult = this.shieldedElements(result);
227             try
228             {
229                 getLinkEnds4r = (Collection<LinkEndFacade>)shieldedResult;
230             }
231             catch (ClassCastException ex)
232             {
233                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
234                 InstanceFacadeLogic.logger.warn("incorrect metafacade cast for InstanceFacadeLogic.getLinkEnds Collection<LinkEndFacade> " + result + ": " + shieldedResult);
235             }
236             // instance has no post constraints
237             this.__getLinkEnds4r = getLinkEnds4r;
238             if (isMetafacadePropertyCachingEnabled())
239             {
240                 this.__getLinkEnds4rSet = true;
241             }
242         }
243         return getLinkEnds4r;
244     }
245 
246     /**
247      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
248      * @return  Collection
249      */
250     protected abstract Collection handleGetLinkEnds();
251 
252     private Collection<ClassifierFacade> __getClassifiers5r;
253     private boolean __getClassifiers5rSet = false;
254 
255     /**
256      * A representation of the model object 'Instance Specification'. Represents an instance in a
257      * modeled
258      * system. Has the capability of being a deployment target in a deployment relationship, in the
259      * case
260      * that it is an instance of a node. Has the capability of being a deployed artifact, if it is
261      * an
262      * instance of an artifact.
263      * @return (Collection<ClassifierFacade>)handleGetClassifiers()
264      */
265     public final Collection<ClassifierFacade> getClassifiers()
266     {
267         Collection<ClassifierFacade> getClassifiers5r = this.__getClassifiers5r;
268         if (!this.__getClassifiers5rSet)
269         {
270             // instanceFacade has no pre constraints
271             Collection result = handleGetClassifiers();
272             List shieldedResult = this.shieldedElements(result);
273             try
274             {
275                 getClassifiers5r = (Collection<ClassifierFacade>)shieldedResult;
276             }
277             catch (ClassCastException ex)
278             {
279                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
280                 InstanceFacadeLogic.logger.warn("incorrect metafacade cast for InstanceFacadeLogic.getClassifiers Collection<ClassifierFacade> " + result + ": " + shieldedResult);
281             }
282             // instanceFacade has no post constraints
283             this.__getClassifiers5r = getClassifiers5r;
284             if (isMetafacadePropertyCachingEnabled())
285             {
286                 this.__getClassifiers5rSet = true;
287             }
288         }
289         return getClassifiers5r;
290     }
291 
292     /**
293      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
294      * @return  Collection
295      */
296     protected abstract Collection handleGetClassifiers();
297 
298     private Collection<AttributeLinkFacade> __getAttributeLinks6r;
299     private boolean __getAttributeLinks6rSet = false;
300 
301     /**
302      * The owning instance for this link.
303      * @return (Collection<AttributeLinkFacade>)handleGetAttributeLinks()
304      */
305     public final Collection<AttributeLinkFacade> getAttributeLinks()
306     {
307         Collection<AttributeLinkFacade> getAttributeLinks6r = this.__getAttributeLinks6r;
308         if (!this.__getAttributeLinks6rSet)
309         {
310             // instance has no pre constraints
311             Collection result = handleGetAttributeLinks();
312             List shieldedResult = this.shieldedElements(result);
313             try
314             {
315                 getAttributeLinks6r = (Collection<AttributeLinkFacade>)shieldedResult;
316             }
317             catch (ClassCastException ex)
318             {
319                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
320                 InstanceFacadeLogic.logger.warn("incorrect metafacade cast for InstanceFacadeLogic.getAttributeLinks Collection<AttributeLinkFacade> " + result + ": " + shieldedResult);
321             }
322             // instance has no post constraints
323             this.__getAttributeLinks6r = getAttributeLinks6r;
324             if (isMetafacadePropertyCachingEnabled())
325             {
326                 this.__getAttributeLinks6rSet = true;
327             }
328         }
329         return getAttributeLinks6r;
330     }
331 
332     /**
333      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
334      * @return  Collection
335      */
336     protected abstract Collection handleGetAttributeLinks();
337 
338     /**
339      * @param validationMessages Collection<ModelValidationMessage>
340      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
341      */
342     @Override
343     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
344     {
345         super.validateInvariants(validationMessages);
346     }
347 }