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.PartitionFacade;
012import org.andromda.metafacades.uml.StateFacade;
013import org.andromda.metafacades.uml.StateMachineFacade;
014import org.andromda.metafacades.uml.StateVertexFacade;
015import org.andromda.metafacades.uml.TransitionFacade;
016import org.apache.log4j.Logger;
017import org.omg.uml.behavioralelements.statemachines.StateVertex;
018
019/**
020 * A representation of the model object 'Vertex'. An abstraction of a node in a state machine graph.
021 * In general, it can be the source or destination of any number of transitions.
022 * MetafacadeLogic for StateVertexFacade
023 *
024 * @see StateVertexFacade
025 */
026public abstract class StateVertexFacadeLogic
027    extends ModelElementFacadeLogicImpl
028    implements StateVertexFacade
029{
030    /**
031     * The underlying UML object
032     * @see StateVertex
033     */
034    protected StateVertex metaObject;
035
036    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
037     * @param metaObjectIn
038     * @param context
039     */
040    protected StateVertexFacadeLogic(StateVertex metaObjectIn, String context)
041    {
042        super(metaObjectIn, getContext(context));
043        this.metaObject = metaObjectIn;
044    }
045
046    /**
047     * The logger instance.
048     */
049    private static final Logger logger = Logger.getLogger(StateVertexFacadeLogic.class);
050
051    /**
052     * Gets the context for this metafacade logic instance.
053     * @param context String. Set to StateVertexFacade if null
054     * @return context String
055     */
056    private static String getContext(String context)
057    {
058        if (context == null)
059        {
060            context = "org.andromda.metafacades.uml.StateVertexFacade";
061        }
062        return context;
063    }
064
065    /** Reset context only for non-root metafacades
066     * @param context
067     */
068    @Override
069    public void resetMetafacadeContext(String context)
070    {
071        if (!this.contextRoot) // reset context only for non-root metafacades
072        {
073            context = getContext(context);  // to have same value as in original constructor call
074            setMetafacadeContext (context);
075        }
076    }
077
078    /**
079     * @return boolean true always
080     * @see StateVertexFacade
081     */
082    public boolean isStateVertexFacadeMetaType()
083    {
084        return true;
085    }
086
087    // ------------- associations ------------------
088
089    /**
090     * A representation of the model object 'Vertex'. An abstraction of a node in a state machine
091     * graph. In
092     * general, it can be the source or destination of any number of transitions.
093     * @return (Collection<TransitionFacade>)handleGetOutgoings()
094     */
095    public final Collection<TransitionFacade> getOutgoings()
096    {
097        Collection<TransitionFacade> getOutgoings1r = null;
098        // target has no pre constraints
099        Collection result = handleGetOutgoings();
100        List shieldedResult = this.shieldedElements(result);
101        try
102        {
103            getOutgoings1r = (Collection<TransitionFacade>)shieldedResult;
104        }
105        catch (ClassCastException ex)
106        {
107            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
108            StateVertexFacadeLogic.logger.warn("incorrect metafacade cast for StateVertexFacadeLogic.getOutgoings Collection<TransitionFacade> " + result + ": " + shieldedResult);
109        }
110        // target has no post constraints
111        return getOutgoings1r;
112    }
113
114    /**
115     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
116     * @return  Collection
117     */
118    protected abstract Collection handleGetOutgoings();
119
120    private PartitionFacade __getPartition2r;
121    private boolean __getPartition2rSet = false;
122
123    /**
124     * All vertices enveloped by this partition.
125     * @return (PartitionFacade)handleGetPartition()
126     */
127    public final PartitionFacade getPartition()
128    {
129        PartitionFacade getPartition2r = this.__getPartition2r;
130        if (!this.__getPartition2rSet)
131        {
132            // vertices has no pre constraints
133            Object result = handleGetPartition();
134            MetafacadeBase shieldedResult = this.shieldedElement(result);
135            try
136            {
137                getPartition2r = (PartitionFacade)shieldedResult;
138            }
139            catch (ClassCastException ex)
140            {
141                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
142                StateVertexFacadeLogic.logger.warn("incorrect metafacade cast for StateVertexFacadeLogic.getPartition PartitionFacade " + result + ": " + shieldedResult);
143            }
144            // vertices has no post constraints
145            this.__getPartition2r = getPartition2r;
146            if (isMetafacadePropertyCachingEnabled())
147            {
148                this.__getPartition2rSet = true;
149            }
150        }
151        return getPartition2r;
152    }
153
154    /**
155     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
156     * @return Object
157     */
158    protected abstract Object handleGetPartition();
159
160    /**
161     * A representation of the model object 'Vertex'. An abstraction of a node in a state machine
162     * graph. In
163     * general, it can be the source or destination of any number of transitions.
164     * @return (Collection<TransitionFacade>)handleGetIncomings()
165     */
166    public final Collection<TransitionFacade> getIncomings()
167    {
168        Collection<TransitionFacade> getIncomings3r = null;
169        // source has no pre constraints
170        Collection result = handleGetIncomings();
171        List shieldedResult = this.shieldedElements(result);
172        try
173        {
174            getIncomings3r = (Collection<TransitionFacade>)shieldedResult;
175        }
176        catch (ClassCastException ex)
177        {
178            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
179            StateVertexFacadeLogic.logger.warn("incorrect metafacade cast for StateVertexFacadeLogic.getIncomings Collection<TransitionFacade> " + result + ": " + shieldedResult);
180        }
181        // source has no post constraints
182        return getIncomings3r;
183    }
184
185    /**
186     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
187     * @return  Collection
188     */
189    protected abstract Collection handleGetIncomings();
190
191    /**
192     * A representation of the model object 'Vertex'. An abstraction of a node in a state machine
193     * graph. In
194     * general, it can be the source or destination of any number of transitions.
195     * @return (StateFacade)handleGetContainer()
196     */
197    public final StateFacade getContainer()
198    {
199        StateFacade getContainer4r = null;
200        // stateVertexFacade has no pre constraints
201        Object result = handleGetContainer();
202        MetafacadeBase shieldedResult = this.shieldedElement(result);
203        try
204        {
205            getContainer4r = (StateFacade)shieldedResult;
206        }
207        catch (ClassCastException ex)
208        {
209            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
210            StateVertexFacadeLogic.logger.warn("incorrect metafacade cast for StateVertexFacadeLogic.getContainer StateFacade " + result + ": " + shieldedResult);
211        }
212        // stateVertexFacade has no post constraints
213        return getContainer4r;
214    }
215
216    /**
217     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
218     * @return Object
219     */
220    protected abstract Object handleGetContainer();
221
222    private StateMachineFacade __getStateMachine5r;
223    private boolean __getStateMachine5rSet = false;
224
225    /**
226     * A representation of the model object 'Vertex'. An abstraction of a node in a state machine
227     * graph. In
228     * general, it can be the source or destination of any number of transitions.
229     * @return (StateMachineFacade)handleGetStateMachine()
230     */
231    public final StateMachineFacade getStateMachine()
232    {
233        StateMachineFacade getStateMachine5r = this.__getStateMachine5r;
234        if (!this.__getStateMachine5rSet)
235        {
236            // stateVertexFacade has no pre constraints
237            Object result = handleGetStateMachine();
238            MetafacadeBase shieldedResult = this.shieldedElement(result);
239            try
240            {
241                getStateMachine5r = (StateMachineFacade)shieldedResult;
242            }
243            catch (ClassCastException ex)
244            {
245                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
246                StateVertexFacadeLogic.logger.warn("incorrect metafacade cast for StateVertexFacadeLogic.getStateMachine StateMachineFacade " + result + ": " + shieldedResult);
247            }
248            // stateVertexFacade has no post constraints
249            this.__getStateMachine5r = getStateMachine5r;
250            if (isMetafacadePropertyCachingEnabled())
251            {
252                this.__getStateMachine5rSet = true;
253            }
254        }
255        return getStateMachine5r;
256    }
257
258    /**
259     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
260     * @return Object
261     */
262    protected abstract Object handleGetStateMachine();
263
264    /**
265     * @param validationMessages Collection<ModelValidationMessage>
266     * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
267     */
268    @Override
269    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
270    {
271        super.validateInvariants(validationMessages);
272    }
273}