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.IncludeFacade;
11  import org.andromda.metafacades.uml.UseCaseFacade;
12  import org.apache.log4j.Logger;
13  import org.omg.uml.behavioralelements.usecases.Include;
14  
15  /**
16   * An include relationship defines that a use case contains the behavior defined in another use
17   * case.
18   * MetafacadeLogic for IncludeFacade
19   *
20   * @see IncludeFacade
21   */
22  public abstract class IncludeFacadeLogic
23      extends ModelElementFacadeLogicImpl
24      implements IncludeFacade
25  {
26      /**
27       * The underlying UML object
28       * @see Include
29       */
30      protected Include metaObject;
31  
32      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
33       * @param metaObjectIn
34       * @param context
35       */
36      protected IncludeFacadeLogic(Include metaObjectIn, String context)
37      {
38          super(metaObjectIn, getContext(context));
39          this.metaObject = metaObjectIn;
40      }
41  
42      /**
43       * The logger instance.
44       */
45      private static final Logger logger = Logger.getLogger(IncludeFacadeLogic.class);
46  
47      /**
48       * Gets the context for this metafacade logic instance.
49       * @param context String. Set to IncludeFacade if null
50       * @return context String
51       */
52      private static String getContext(String context)
53      {
54          if (context == null)
55          {
56              context = "org.andromda.metafacades.uml.IncludeFacade";
57          }
58          return context;
59      }
60  
61      /** Reset context only for non-root metafacades
62       * @param context
63       */
64      @Override
65      public void resetMetafacadeContext(String context)
66      {
67          if (!this.contextRoot) // reset context only for non-root metafacades
68          {
69              context = getContext(context);  // to have same value as in original constructor call
70              setMetafacadeContext (context);
71          }
72      }
73  
74      /**
75       * @return boolean true always
76       * @see IncludeFacade
77       */
78      public boolean isIncludeFacadeMetaType()
79      {
80          return true;
81      }
82  
83      // ------------- associations ------------------
84  
85      /**
86       * An include relationship defines that a use case contains the behavior defined in another use
87       * case.
88       * @return (UseCaseFacade)handleGetAddition()
89       */
90      public final UseCaseFacade getAddition()
91      {
92          UseCaseFacade getAddition1r = null;
93          // includeFacade has no pre constraints
94          Object result = handleGetAddition();
95          MetafacadeBase shieldedResult = this.shieldedElement(result);
96          try
97          {
98              getAddition1r = (UseCaseFacade)shieldedResult;
99          }
100         catch (ClassCastException ex)
101         {
102             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
103             IncludeFacadeLogic.logger.warn("incorrect metafacade cast for IncludeFacadeLogic.getAddition UseCaseFacade " + result + ": " + shieldedResult);
104         }
105         // includeFacade has no post constraints
106         return getAddition1r;
107     }
108 
109     /**
110      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
111      * @return Object
112      */
113     protected abstract Object handleGetAddition();
114 
115     /**
116      * The included instances related to this use-case.
117      * @return (UseCaseFacade)handleGetBase()
118      */
119     public final UseCaseFacade getBase()
120     {
121         UseCaseFacade getBase2r = null;
122         // includes has no pre constraints
123         Object result = handleGetBase();
124         MetafacadeBase shieldedResult = this.shieldedElement(result);
125         try
126         {
127             getBase2r = (UseCaseFacade)shieldedResult;
128         }
129         catch (ClassCastException ex)
130         {
131             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
132             IncludeFacadeLogic.logger.warn("incorrect metafacade cast for IncludeFacadeLogic.getBase UseCaseFacade " + result + ": " + shieldedResult);
133         }
134         // includes has no post constraints
135         return getBase2r;
136     }
137 
138     /**
139      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
140      * @return Object
141      */
142     protected abstract Object handleGetBase();
143 
144     /**
145      * @param validationMessages Collection<ModelValidationMessage>
146      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
147      */
148     @Override
149     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
150     {
151         super.validateInvariants(validationMessages);
152     }
153 }