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.ExtensionPointFacade;
11  import org.andromda.metafacades.uml.UseCaseFacade;
12  import org.apache.log4j.Logger;
13  import org.omg.uml.behavioralelements.usecases.ExtensionPoint;
14  
15  /**
16   * Identifies a point in the behavior of a use case where that behavior can be extended by the
17   * behavior of some other (extending) use case, as specified by an extend relationship.
18   * MetafacadeLogic for ExtensionPointFacade
19   *
20   * @see ExtensionPointFacade
21   */
22  public abstract class ExtensionPointFacadeLogic
23      extends ModelElementFacadeLogicImpl
24      implements ExtensionPointFacade
25  {
26      /**
27       * The underlying UML object
28       * @see ExtensionPoint
29       */
30      protected ExtensionPoint metaObject;
31  
32      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
33       * @param metaObjectIn
34       * @param context
35       */
36      protected ExtensionPointFacadeLogic(ExtensionPoint 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(ExtensionPointFacadeLogic.class);
46  
47      /**
48       * Gets the context for this metafacade logic instance.
49       * @param context String. Set to ExtensionPointFacade 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.ExtensionPointFacade";
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 ExtensionPointFacade
77       */
78      public boolean isExtensionPointFacadeMetaType()
79      {
80          return true;
81      }
82  
83      // ------------- associations ------------------
84  
85      private UseCaseFacade __getUseCase1r;
86      private boolean __getUseCase1rSet = false;
87  
88      /**
89       * The extension points related to this use-case.
90       * @return (UseCaseFacade)handleGetUseCase()
91       */
92      public final UseCaseFacade getUseCase()
93      {
94          UseCaseFacade getUseCase1r = this.__getUseCase1r;
95          if (!this.__getUseCase1rSet)
96          {
97              // extensionPoints has no pre constraints
98              Object result = handleGetUseCase();
99              MetafacadeBase shieldedResult = this.shieldedElement(result);
100             try
101             {
102                 getUseCase1r = (UseCaseFacade)shieldedResult;
103             }
104             catch (ClassCastException ex)
105             {
106                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
107                 ExtensionPointFacadeLogic.logger.warn("incorrect metafacade cast for ExtensionPointFacadeLogic.getUseCase UseCaseFacade " + result + ": " + shieldedResult);
108             }
109             // extensionPoints has no post constraints
110             this.__getUseCase1r = getUseCase1r;
111             if (isMetafacadePropertyCachingEnabled())
112             {
113                 this.__getUseCase1rSet = true;
114             }
115         }
116         return getUseCase1r;
117     }
118 
119     /**
120      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
121      * @return Object
122      */
123     protected abstract Object handleGetUseCase();
124 
125     /**
126      * @param validationMessages Collection<ModelValidationMessage>
127      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
128      */
129     @Override
130     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
131     {
132         super.validateInvariants(validationMessages);
133     }
134 }