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.GuardFacade;
11 import org.andromda.metafacades.uml.TransitionFacade;
12 import org.apache.log4j.Logger;
13 import org.omg.uml.behavioralelements.statemachines.Guard;
14
15 /**
16 * A representation of the model object 'Constraint'. A condition or restriction expressed in
17 * natural language text or in a machine readable language for the purpose of declaring some of the
18 * semantics of an element.
19 * MetafacadeLogic for GuardFacade
20 *
21 * @see GuardFacade
22 */
23 public abstract class GuardFacadeLogic
24 extends ModelElementFacadeLogicImpl
25 implements GuardFacade
26 {
27 /**
28 * The underlying UML object
29 * @see Guard
30 */
31 protected Guard metaObject;
32
33 /** Create Metafacade implementation instance using the MetafacadeFactory from the context
34 * @param metaObjectIn
35 * @param context
36 */
37 protected GuardFacadeLogic(Guard 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(GuardFacadeLogic.class);
47
48 /**
49 * Gets the context for this metafacade logic instance.
50 * @param context String. Set to GuardFacade 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.GuardFacade";
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 GuardFacade
78 */
79 public boolean isGuardFacadeMetaType()
80 {
81 return true;
82 }
83
84 // --------------- attributes ---------------------
85
86 /**
87 * @see GuardFacade#getBody()
88 * @return String
89 */
90 protected abstract String handleGetBody();
91
92 /**
93 * TODO: Model Documentation for GuardFacade.body
94 * @return (String)handleGetBody()
95 */
96 public final String getBody()
97 {
98 String body1a = null;
99 // body has no pre constraints
100 body1a = handleGetBody();
101 // body has no post constraints
102 return body1a;
103 }
104
105 // ------------- associations ------------------
106
107 /**
108 * A representation of the model object 'Constraint'. A condition or restriction expressed in
109 * natural
110 * language text or in a machine readable language for the purpose of declaring some of the
111 * semantics
112 * of an element.
113 * @return (TransitionFacade)handleGetTransition()
114 */
115 public final TransitionFacade getTransition()
116 {
117 TransitionFacade getTransition1r = null;
118 // guard has no pre constraints
119 Object result = handleGetTransition();
120 MetafacadeBase shieldedResult = this.shieldedElement(result);
121 try
122 {
123 getTransition1r = (TransitionFacade)shieldedResult;
124 }
125 catch (ClassCastException ex)
126 {
127 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
128 GuardFacadeLogic.logger.warn("incorrect metafacade cast for GuardFacadeLogic.getTransition TransitionFacade " + result + ": " + shieldedResult);
129 }
130 // guard has no post constraints
131 return getTransition1r;
132 }
133
134 /**
135 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
136 * @return Object
137 */
138 protected abstract Object handleGetTransition();
139
140 /**
141 * @param validationMessages Collection<ModelValidationMessage>
142 * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
143 */
144 @Override
145 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
146 {
147 super.validateInvariants(validationMessages);
148 }
149 }