001// license-header java merge-point
002//
003// Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
004//
005package org.andromda.metafacades.uml14;
006
007import java.util.Collection;
008import java.util.List;
009import org.andromda.core.metafacade.MetafacadeBase;
010import org.andromda.core.metafacade.ModelValidationMessage;
011import org.andromda.metafacades.uml.FinalStateFacade;
012import org.andromda.metafacades.uml.ModelElementFacade;
013import org.andromda.metafacades.uml.PseudostateFacade;
014import org.andromda.metafacades.uml.StateFacade;
015import org.andromda.metafacades.uml.StateMachineFacade;
016import org.andromda.metafacades.uml.TransitionFacade;
017import org.apache.log4j.Logger;
018import org.omg.uml.behavioralelements.statemachines.StateMachine;
019
020/**
021 * State machines can be used to express the behavior of part of a system. Behavior is modeled as a
022 * traversal of a graph of state nodes interconnected by one or more joined transition arcs that are
023 * triggered by the dispatching of series of (event) occurrences. During this traversal, the state
024 * machine executes a series of activities associated with various elements of the state machine.
025 * MetafacadeLogic for StateMachineFacade
026 *
027 * @see StateMachineFacade
028 */
029public abstract class StateMachineFacadeLogic
030    extends ModelElementFacadeLogicImpl
031    implements StateMachineFacade
032{
033    /**
034     * The underlying UML object
035     * @see StateMachine
036     */
037    protected StateMachine metaObject;
038
039    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
040     * @param metaObjectIn
041     * @param context
042     */
043    protected StateMachineFacadeLogic(StateMachine metaObjectIn, String context)
044    {
045        super(metaObjectIn, getContext(context));
046        this.metaObject = metaObjectIn;
047    }
048
049    /**
050     * The logger instance.
051     */
052    private static final Logger logger = Logger.getLogger(StateMachineFacadeLogic.class);
053
054    /**
055     * Gets the context for this metafacade logic instance.
056     * @param context String. Set to StateMachineFacade if null
057     * @return context String
058     */
059    private static String getContext(String context)
060    {
061        if (context == null)
062        {
063            context = "org.andromda.metafacades.uml.StateMachineFacade";
064        }
065        return context;
066    }
067
068    /** Reset context only for non-root metafacades
069     * @param context
070     */
071    @Override
072    public void resetMetafacadeContext(String context)
073    {
074        if (!this.contextRoot) // reset context only for non-root metafacades
075        {
076            context = getContext(context);  // to have same value as in original constructor call
077            setMetafacadeContext (context);
078        }
079    }
080
081    /**
082     * @return boolean true always
083     * @see StateMachineFacade
084     */
085    public boolean isStateMachineFacadeMetaType()
086    {
087        return true;
088    }
089
090    // ------------- associations ------------------
091
092    private Collection<StateFacade> __getStates1r;
093    private boolean __getStates1rSet = false;
094
095    /**
096     * State machines can be used to express the behavior of part of a system. Behavior is modeled
097     * as a
098     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
099     * are
100     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
101     * state
102     * machine executes a series of activities associated with various elements of the state
103     * machine.
104     * @return (Collection<StateFacade>)handleGetStates()
105     */
106    public final Collection<StateFacade> getStates()
107    {
108        Collection<StateFacade> getStates1r = this.__getStates1r;
109        if (!this.__getStates1rSet)
110        {
111            // stateMachineFacade has no pre constraints
112            Collection result = handleGetStates();
113            List shieldedResult = this.shieldedElements(result);
114            try
115            {
116                getStates1r = (Collection<StateFacade>)shieldedResult;
117            }
118            catch (ClassCastException ex)
119            {
120                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
121                StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getStates Collection<StateFacade> " + result + ": " + shieldedResult);
122            }
123            // stateMachineFacade has no post constraints
124            this.__getStates1r = getStates1r;
125            if (isMetafacadePropertyCachingEnabled())
126            {
127                this.__getStates1rSet = true;
128            }
129        }
130        return getStates1r;
131    }
132
133    /**
134     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
135     * @return  Collection
136     */
137    protected abstract Collection handleGetStates();
138
139    private PseudostateFacade __getInitialState2r;
140    private boolean __getInitialState2rSet = false;
141
142    /**
143     * State machines can be used to express the behavior of part of a system. Behavior is modeled
144     * as a
145     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
146     * are
147     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
148     * state
149     * machine executes a series of activities associated with various elements of the state
150     * machine.
151     * @return (PseudostateFacade)handleGetInitialState()
152     */
153    public final PseudostateFacade getInitialState()
154    {
155        PseudostateFacade getInitialState2r = this.__getInitialState2r;
156        if (!this.__getInitialState2rSet)
157        {
158            // stateMachineFacade has no pre constraints
159            Object result = handleGetInitialState();
160            MetafacadeBase shieldedResult = this.shieldedElement(result);
161            try
162            {
163                getInitialState2r = (PseudostateFacade)shieldedResult;
164            }
165            catch (ClassCastException ex)
166            {
167                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
168                StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getInitialState PseudostateFacade " + result + ": " + shieldedResult);
169            }
170            // stateMachineFacade has no post constraints
171            this.__getInitialState2r = getInitialState2r;
172            if (isMetafacadePropertyCachingEnabled())
173            {
174                this.__getInitialState2rSet = true;
175            }
176        }
177        return getInitialState2r;
178    }
179
180    /**
181     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
182     * @return Object
183     */
184    protected abstract Object handleGetInitialState();
185
186    /**
187     * State machines can be used to express the behavior of part of a system. Behavior is modeled
188     * as a
189     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
190     * are
191     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
192     * state
193     * machine executes a series of activities associated with various elements of the state
194     * machine.
195     * @return (Collection<PseudostateFacade>)handleGetInitialStates()
196     */
197    public final Collection<PseudostateFacade> getInitialStates()
198    {
199        Collection<PseudostateFacade> getInitialStates3r = null;
200        // stateMachineFacade has no pre constraints
201        Collection result = handleGetInitialStates();
202        List shieldedResult = this.shieldedElements(result);
203        try
204        {
205            getInitialStates3r = (Collection<PseudostateFacade>)shieldedResult;
206        }
207        catch (ClassCastException ex)
208        {
209            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
210            StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getInitialStates Collection<PseudostateFacade> " + result + ": " + shieldedResult);
211        }
212        // stateMachineFacade has no post constraints
213        return getInitialStates3r;
214    }
215
216    /**
217     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
218     * @return  Collection
219     */
220    protected abstract Collection handleGetInitialStates();
221
222    /**
223     * State machines can be used to express the behavior of part of a system. Behavior is modeled
224     * as a
225     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
226     * are
227     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
228     * state
229     * machine executes a series of activities associated with various elements of the state
230     * machine.
231     * @return (Collection<PseudostateFacade>)handleGetPseudostates()
232     */
233    public final Collection<PseudostateFacade> getPseudostates()
234    {
235        Collection<PseudostateFacade> getPseudostates4r = null;
236        // stateMachineFacade has no pre constraints
237        Collection result = handleGetPseudostates();
238        List shieldedResult = this.shieldedElements(result);
239        try
240        {
241            getPseudostates4r = (Collection<PseudostateFacade>)shieldedResult;
242        }
243        catch (ClassCastException ex)
244        {
245            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
246            StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getPseudostates Collection<PseudostateFacade> " + result + ": " + shieldedResult);
247        }
248        // stateMachineFacade has no post constraints
249        return getPseudostates4r;
250    }
251
252    /**
253     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
254     * @return  Collection
255     */
256    protected abstract Collection handleGetPseudostates();
257
258    /**
259     * State machines can be used to express the behavior of part of a system. Behavior is modeled
260     * as a
261     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
262     * are
263     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
264     * state
265     * machine executes a series of activities associated with various elements of the state
266     * machine.
267     * @return (Collection<TransitionFacade>)handleGetTransitions()
268     */
269    public final Collection<TransitionFacade> getTransitions()
270    {
271        Collection<TransitionFacade> getTransitions5r = null;
272        // stateMachineFacade has no pre constraints
273        Collection result = handleGetTransitions();
274        List shieldedResult = this.shieldedElements(result);
275        try
276        {
277            getTransitions5r = (Collection<TransitionFacade>)shieldedResult;
278        }
279        catch (ClassCastException ex)
280        {
281            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
282            StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getTransitions Collection<TransitionFacade> " + result + ": " + shieldedResult);
283        }
284        // stateMachineFacade has no post constraints
285        return getTransitions5r;
286    }
287
288    /**
289     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
290     * @return  Collection
291     */
292    protected abstract Collection handleGetTransitions();
293
294    private TransitionFacade __getInitialTransition6r;
295    private boolean __getInitialTransition6rSet = false;
296
297    /**
298     * State machines can be used to express the behavior of part of a system. Behavior is modeled
299     * as a
300     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
301     * are
302     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
303     * state
304     * machine executes a series of activities associated with various elements of the state
305     * machine.
306     * @return (TransitionFacade)handleGetInitialTransition()
307     */
308    public final TransitionFacade getInitialTransition()
309    {
310        TransitionFacade getInitialTransition6r = this.__getInitialTransition6r;
311        if (!this.__getInitialTransition6rSet)
312        {
313            // stateMachineFacade has no pre constraints
314            Object result = handleGetInitialTransition();
315            MetafacadeBase shieldedResult = this.shieldedElement(result);
316            try
317            {
318                getInitialTransition6r = (TransitionFacade)shieldedResult;
319            }
320            catch (ClassCastException ex)
321            {
322                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
323                StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getInitialTransition TransitionFacade " + result + ": " + shieldedResult);
324            }
325            // stateMachineFacade has no post constraints
326            this.__getInitialTransition6r = getInitialTransition6r;
327            if (isMetafacadePropertyCachingEnabled())
328            {
329                this.__getInitialTransition6rSet = true;
330            }
331        }
332        return getInitialTransition6r;
333    }
334
335    /**
336     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
337     * @return Object
338     */
339    protected abstract Object handleGetInitialTransition();
340
341    /**
342     * State machines can be used to express the behavior of part of a system. Behavior is modeled
343     * as a
344     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
345     * are
346     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
347     * state
348     * machine executes a series of activities associated with various elements of the state
349     * machine.
350     * @return (Collection<FinalStateFacade>)handleGetFinalStates()
351     */
352    public final Collection<FinalStateFacade> getFinalStates()
353    {
354        Collection<FinalStateFacade> getFinalStates7r = null;
355        // stateMachineFacade has no pre constraints
356        Collection result = handleGetFinalStates();
357        List shieldedResult = this.shieldedElements(result);
358        try
359        {
360            getFinalStates7r = (Collection<FinalStateFacade>)shieldedResult;
361        }
362        catch (ClassCastException ex)
363        {
364            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
365            StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getFinalStates Collection<FinalStateFacade> " + result + ": " + shieldedResult);
366        }
367        // stateMachineFacade has no post constraints
368        return getFinalStates7r;
369    }
370
371    /**
372     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
373     * @return  Collection
374     */
375    protected abstract Collection handleGetFinalStates();
376
377    /**
378     * If this model element is the context of an activity graph, this represents that activity
379     * graph.
380     * @return (ModelElementFacade)handleGetContextElement()
381     */
382    public final ModelElementFacade getContextElement()
383    {
384        ModelElementFacade getContextElement8r = null;
385        // stateMachineContext has no pre constraints
386        Object result = handleGetContextElement();
387        MetafacadeBase shieldedResult = this.shieldedElement(result);
388        try
389        {
390            getContextElement8r = (ModelElementFacade)shieldedResult;
391        }
392        catch (ClassCastException ex)
393        {
394            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
395            StateMachineFacadeLogic.logger.warn("incorrect metafacade cast for StateMachineFacadeLogic.getContextElement ModelElementFacade " + result + ": " + shieldedResult);
396        }
397        // stateMachineContext has no post constraints
398        return getContextElement8r;
399    }
400
401    /**
402     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
403     * @return Object
404     */
405    protected abstract Object handleGetContextElement();
406
407    /**
408     * @param validationMessages Collection<ModelValidationMessage>
409     * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
410     */
411    @Override
412    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
413    {
414        super.validateInvariants(validationMessages);
415    }
416}