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