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.ModelElementFacade;
11  import org.andromda.metafacades.uml.NamespaceFacade;
12  import org.apache.log4j.Logger;
13  import org.omg.uml.foundation.core.Classifier;
14  
15  /**
16   * An element in a model that contains a set of named elements that can be identified by name.
17   * MetafacadeLogic for NamespaceFacade
18   *
19   * @see NamespaceFacade
20   */
21  public abstract class NamespaceFacadeLogic
22      extends ClassifierFacadeLogicImpl
23      implements NamespaceFacade
24  {
25      /**
26       * The underlying UML object
27       * @see Object
28       */
29      protected Object metaObject;
30  
31      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
32       * @param metaObjectIn
33       * @param context
34       */
35      protected NamespaceFacadeLogic(Object metaObjectIn, String context)
36      {
37          super((Classifier)metaObjectIn, getContext(context));
38          this.metaObject = metaObjectIn;
39      }
40  
41      /**
42       * The logger instance.
43       */
44      private static final Logger logger = Logger.getLogger(NamespaceFacadeLogic.class);
45  
46      /**
47       * Gets the context for this metafacade logic instance.
48       * @param context String. Set to NamespaceFacade if null
49       * @return context String
50       */
51      private static String getContext(String context)
52      {
53          if (context == null)
54          {
55              context = "org.andromda.metafacades.uml.NamespaceFacade";
56          }
57          return context;
58      }
59  
60      /** Reset context only for non-root metafacades
61       * @param context
62       */
63      @Override
64      public void resetMetafacadeContext(String context)
65      {
66          if (!this.contextRoot) // reset context only for non-root metafacades
67          {
68              context = getContext(context);  // to have same value as in original constructor call
69              setMetafacadeContext (context);
70          }
71      }
72  
73      /**
74       * @return boolean true always
75       * @see NamespaceFacade
76       */
77      public boolean isNamespaceFacadeMetaType()
78      {
79          return true;
80      }
81  
82      // ------------- associations ------------------
83  
84      /**
85       * Gets the namespace to which this model element belongs.
86       * @return (Collection<ModelElementFacade>)handleGetOwnedElements()
87       */
88      public final Collection<ModelElementFacade> getOwnedElements()
89      {
90          Collection<ModelElementFacade> getOwnedElements1r = null;
91          // namespace has no pre constraints
92          Collection result = handleGetOwnedElements();
93          List shieldedResult = this.shieldedElements(result);
94          try
95          {
96              getOwnedElements1r = (Collection<ModelElementFacade>)shieldedResult;
97          }
98          catch (ClassCastException ex)
99          {
100             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
101             NamespaceFacadeLogic.logger.warn("incorrect metafacade cast for NamespaceFacadeLogic.getOwnedElements Collection<ModelElementFacade> " + result + ": " + shieldedResult);
102         }
103         // namespace has no post constraints
104         return getOwnedElements1r;
105     }
106 
107     /**
108      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
109      * @return  Collection
110      */
111     protected abstract Collection handleGetOwnedElements();
112 
113     /**
114      * @param validationMessages Collection<ModelValidationMessage>
115      * @see ClassifierFacadeLogicImpl#validateInvariants(Collection validationMessages)
116      */
117     @Override
118     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
119     {
120         super.validateInvariants(validationMessages);
121     }
122 }