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.FrontEndFinalState;
012import org.andromda.metafacades.uml.FrontEndParameter;
013import org.andromda.metafacades.uml.FrontEndUseCase;
014import org.apache.log4j.Logger;
015import org.omg.uml.behavioralelements.statemachines.FinalState;
016
017/**
018 * A final state represents the end of a use-case, in a "front-end" application this means its the
019 * transition into the next front-end use case.
020 * MetafacadeLogic for FrontEndFinalState
021 *
022 * @see FrontEndFinalState
023 */
024public abstract class FrontEndFinalStateLogic
025    extends FinalStateFacadeLogicImpl
026    implements FrontEndFinalState
027{
028    /**
029     * The underlying UML object
030     * @see Object
031     */
032    protected Object metaObject;
033
034    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
035     * @param metaObjectIn
036     * @param context
037     */
038    protected FrontEndFinalStateLogic(Object metaObjectIn, String context)
039    {
040        super((FinalState)metaObjectIn, getContext(context));
041        this.metaObject = metaObjectIn;
042    }
043
044    /**
045     * The logger instance.
046     */
047    private static final Logger logger = Logger.getLogger(FrontEndFinalStateLogic.class);
048
049    /**
050     * Gets the context for this metafacade logic instance.
051     * @param context String. Set to FrontEndFinalState if null
052     * @return context String
053     */
054    private static String getContext(String context)
055    {
056        if (context == null)
057        {
058            context = "org.andromda.metafacades.uml.FrontEndFinalState";
059        }
060        return context;
061    }
062
063    /** Reset context only for non-root metafacades
064     * @param context
065     */
066    @Override
067    public void resetMetafacadeContext(String context)
068    {
069        if (!this.contextRoot) // reset context only for non-root metafacades
070        {
071            context = getContext(context);  // to have same value as in original constructor call
072            setMetafacadeContext (context);
073        }
074    }
075
076    /**
077     * @return boolean true always
078     * @see FrontEndFinalState
079     */
080    public boolean isFrontEndFinalStateMetaType()
081    {
082        return true;
083    }
084
085    // --------------- attributes ---------------------
086
087   /**
088    * @see FrontEndFinalState#isContainedInFrontEndUseCase()
089    * @return boolean
090    */
091    protected abstract boolean handleIsContainedInFrontEndUseCase();
092
093    private boolean __containedInFrontEndUseCase1a;
094    private boolean __containedInFrontEndUseCase1aSet = false;
095
096    /**
097     * Indicates if this front end final state is contained within a FrontEndUseCase.
098     * @return (boolean)handleIsContainedInFrontEndUseCase()
099     */
100    public final boolean isContainedInFrontEndUseCase()
101    {
102        boolean containedInFrontEndUseCase1a = this.__containedInFrontEndUseCase1a;
103        if (!this.__containedInFrontEndUseCase1aSet)
104        {
105            // containedInFrontEndUseCase has no pre constraints
106            containedInFrontEndUseCase1a = handleIsContainedInFrontEndUseCase();
107            // containedInFrontEndUseCase has no post constraints
108            this.__containedInFrontEndUseCase1a = containedInFrontEndUseCase1a;
109            if (isMetafacadePropertyCachingEnabled())
110            {
111                this.__containedInFrontEndUseCase1aSet = true;
112            }
113        }
114        return containedInFrontEndUseCase1a;
115    }
116
117    // ------------- associations ------------------
118
119    private FrontEndUseCase __getTargetUseCase1r;
120    private boolean __getTargetUseCase1rSet = false;
121
122    /**
123     * The final states linking to this use case
124     * @return (FrontEndUseCase)handleGetTargetUseCase()
125     */
126    public final FrontEndUseCase getTargetUseCase()
127    {
128        FrontEndUseCase getTargetUseCase1r = this.__getTargetUseCase1r;
129        if (!this.__getTargetUseCase1rSet)
130        {
131            // referencingFinalStates has no pre constraints
132            Object result = handleGetTargetUseCase();
133            MetafacadeBase shieldedResult = this.shieldedElement(result);
134            try
135            {
136                getTargetUseCase1r = (FrontEndUseCase)shieldedResult;
137            }
138            catch (ClassCastException ex)
139            {
140                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
141                FrontEndFinalStateLogic.logger.warn("incorrect metafacade cast for FrontEndFinalStateLogic.getTargetUseCase FrontEndUseCase " + result + ": " + shieldedResult);
142            }
143            // referencingFinalStates has no post constraints
144            this.__getTargetUseCase1r = getTargetUseCase1r;
145            if (isMetafacadePropertyCachingEnabled())
146            {
147                this.__getTargetUseCase1rSet = true;
148            }
149        }
150        return getTargetUseCase1r;
151    }
152
153    /**
154     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
155     * @return Object
156     */
157    protected abstract Object handleGetTargetUseCase();
158
159    private List<FrontEndParameter> __getInterUseCaseParameters2r;
160    private boolean __getInterUseCaseParameters2rSet = false;
161
162    /**
163     * A final state represents the end of a use-case, in a "front-end" application this means its
164     * the
165     * transition into the next front-end use case.
166     * @return (List<FrontEndParameter>)handleGetInterUseCaseParameters()
167     */
168    public final List<FrontEndParameter> getInterUseCaseParameters()
169    {
170        List<FrontEndParameter> getInterUseCaseParameters2r = this.__getInterUseCaseParameters2r;
171        if (!this.__getInterUseCaseParameters2rSet)
172        {
173            // frontEndFinalState has no pre constraints
174            List result = handleGetInterUseCaseParameters();
175            List shieldedResult = this.shieldedElements(result);
176            try
177            {
178                getInterUseCaseParameters2r = (List<FrontEndParameter>)shieldedResult;
179            }
180            catch (ClassCastException ex)
181            {
182                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
183                FrontEndFinalStateLogic.logger.warn("incorrect metafacade cast for FrontEndFinalStateLogic.getInterUseCaseParameters List<FrontEndParameter> " + result + ": " + shieldedResult);
184            }
185            // frontEndFinalState has no post constraints
186            this.__getInterUseCaseParameters2r = getInterUseCaseParameters2r;
187            if (isMetafacadePropertyCachingEnabled())
188            {
189                this.__getInterUseCaseParameters2rSet = true;
190            }
191        }
192        return getInterUseCaseParameters2r;
193    }
194
195    /**
196     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
197     * @return  List
198     */
199    protected abstract List handleGetInterUseCaseParameters();
200
201    /**
202     * @param validationMessages Collection<ModelValidationMessage>
203     * @see FinalStateFacadeLogicImpl#validateInvariants(Collection validationMessages)
204     */
205    @Override
206    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
207    {
208        super.validateInvariants(validationMessages);
209    }
210}