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