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 org.andromda.core.metafacade.MetafacadeBase;
9   import org.andromda.core.metafacade.ModelValidationMessage;
10  import org.andromda.metafacades.uml.DependencyFacade;
11  import org.andromda.metafacades.uml.ModelElementFacade;
12  import org.apache.log4j.Logger;
13  import org.omg.uml.foundation.core.Dependency;
14  
15  /**
16   * A representation of the model object 'Directed Relationship'.Represents a relationship between a
17   * collection of source model elements and a collection of target model elements, a
18   * dependency/reference.
19   * MetafacadeLogic for DependencyFacade
20   *
21   * @see DependencyFacade
22   */
23  public abstract class DependencyFacadeLogic
24      extends ModelElementFacadeLogicImpl
25      implements DependencyFacade
26  {
27      /**
28       * The underlying UML object
29       * @see Dependency
30       */
31      protected Dependency metaObject;
32  
33      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
34       * @param metaObjectIn
35       * @param context
36       */
37      protected DependencyFacadeLogic(Dependency 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(DependencyFacadeLogic.class);
47  
48      /**
49       * Gets the context for this metafacade logic instance.
50       * @param context String. Set to DependencyFacade 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.DependencyFacade";
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 DependencyFacade
78       */
79      public boolean isDependencyFacadeMetaType()
80      {
81          return true;
82      }
83  
84      // --------------- attributes ---------------------
85  
86     /**
87      * @see DependencyFacade#getGetterName()
88      * @return String
89      */
90      protected abstract String handleGetGetterName();
91  
92      private String __getterName1a;
93      private boolean __getterName1aSet = false;
94  
95      /**
96       * The "getter" name for this dependency.
97       * @return (String)handleGetGetterName()
98       */
99      public final String getGetterName()
100     {
101         String getterName1a = this.__getterName1a;
102         if (!this.__getterName1aSet)
103         {
104             // getterName has no pre constraints
105             getterName1a = handleGetGetterName();
106             // getterName has no post constraints
107             this.__getterName1a = getterName1a;
108             if (isMetafacadePropertyCachingEnabled())
109             {
110                 this.__getterName1aSet = true;
111             }
112         }
113         return getterName1a;
114     }
115 
116    /**
117     * @see DependencyFacade#getSetterName()
118     * @return String
119     */
120     protected abstract String handleGetSetterName();
121 
122     private String __setterName2a;
123     private boolean __setterName2aSet = false;
124 
125     /**
126      * The "setter" name for this dependency.
127      * @return (String)handleGetSetterName()
128      */
129     public final String getSetterName()
130     {
131         String setterName2a = this.__setterName2a;
132         if (!this.__setterName2aSet)
133         {
134             // setterName has no pre constraints
135             setterName2a = handleGetSetterName();
136             // setterName has no post constraints
137             this.__setterName2a = setterName2a;
138             if (isMetafacadePropertyCachingEnabled())
139             {
140                 this.__setterName2aSet = true;
141             }
142         }
143         return setterName2a;
144     }
145 
146     // ------------- associations ------------------
147 
148     /**
149      * Gets the dependencies for which this model element is the source.
150      * @return (ModelElementFacade)handleGetSourceElement()
151      */
152     public final ModelElementFacade getSourceElement()
153     {
154         ModelElementFacade getSourceElement1r = null;
155         // sourceDependencies has no pre constraints
156         Object result = handleGetSourceElement();
157         MetafacadeBase shieldedResult = this.shieldedElement(result);
158         try
159         {
160             getSourceElement1r = (ModelElementFacade)shieldedResult;
161         }
162         catch (ClassCastException ex)
163         {
164             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
165             DependencyFacadeLogic.logger.warn("incorrect metafacade cast for DependencyFacadeLogic.getSourceElement ModelElementFacade " + result + ": " + shieldedResult);
166         }
167         // sourceDependencies has no post constraints
168         return getSourceElement1r;
169     }
170 
171     /**
172      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
173      * @return Object
174      */
175     protected abstract Object handleGetSourceElement();
176 
177     /**
178      * Gets the dependencies for which this model element is the target.
179      * @return (ModelElementFacade)handleGetTargetElement()
180      */
181     public final ModelElementFacade getTargetElement()
182     {
183         ModelElementFacade getTargetElement2r = null;
184         // targetDependencies has no pre constraints
185         Object result = handleGetTargetElement();
186         MetafacadeBase shieldedResult = this.shieldedElement(result);
187         try
188         {
189             getTargetElement2r = (ModelElementFacade)shieldedResult;
190         }
191         catch (ClassCastException ex)
192         {
193             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
194             DependencyFacadeLogic.logger.warn("incorrect metafacade cast for DependencyFacadeLogic.getTargetElement ModelElementFacade " + result + ": " + shieldedResult);
195         }
196         // targetDependencies has no post constraints
197         return getTargetElement2r;
198     }
199 
200     /**
201      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
202      * @return Object
203      */
204     protected abstract Object handleGetTargetElement();
205 
206     /**
207      * @param validationMessages Collection<ModelValidationMessage>
208      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
209      */
210     @Override
211     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
212     {
213         super.validateInvariants(validationMessages);
214     }
215 }