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.ModelValidationMessage;
010import org.andromda.metafacades.uml.FrontEndAction;
011import org.andromda.metafacades.uml.FrontEndPseudostate;
012import org.apache.log4j.Logger;
013import org.omg.uml.behavioralelements.statemachines.Pseudostate;
014
015/**
016 * Encapsulates a pseudostate and provides specific front-end services. This pseudostate can be a
017 * decision point, junction or initial state.
018 * MetafacadeLogic for FrontEndPseudostate
019 *
020 * @see FrontEndPseudostate
021 */
022public abstract class FrontEndPseudostateLogic
023    extends PseudostateFacadeLogicImpl
024    implements FrontEndPseudostate
025{
026    /**
027     * The underlying UML object
028     * @see Object
029     */
030    protected Object metaObject;
031
032    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
033     * @param metaObjectIn
034     * @param context
035     */
036    protected FrontEndPseudostateLogic(Object metaObjectIn, String context)
037    {
038        super((Pseudostate)metaObjectIn, getContext(context));
039        this.metaObject = metaObjectIn;
040    }
041
042    /**
043     * The logger instance.
044     */
045    private static final Logger logger = Logger.getLogger(FrontEndPseudostateLogic.class);
046
047    /**
048     * Gets the context for this metafacade logic instance.
049     * @param context String. Set to FrontEndPseudostate if null
050     * @return context String
051     */
052    private static String getContext(String context)
053    {
054        if (context == null)
055        {
056            context = "org.andromda.metafacades.uml.FrontEndPseudostate";
057        }
058        return context;
059    }
060
061    /** Reset context only for non-root metafacades
062     * @param context
063     */
064    @Override
065    public void resetMetafacadeContext(String context)
066    {
067        if (!this.contextRoot) // reset context only for non-root metafacades
068        {
069            context = getContext(context);  // to have same value as in original constructor call
070            setMetafacadeContext (context);
071        }
072    }
073
074    /**
075     * @return boolean true always
076     * @see FrontEndPseudostate
077     */
078    public boolean isFrontEndPseudostateMetaType()
079    {
080        return true;
081    }
082
083    // --------------- attributes ---------------------
084
085   /**
086    * @see FrontEndPseudostate#isContainedInFrontEndUseCase()
087    * @return boolean
088    */
089    protected abstract boolean handleIsContainedInFrontEndUseCase();
090
091    private boolean __containedInFrontEndUseCase1a;
092    private boolean __containedInFrontEndUseCase1aSet = false;
093
094    /**
095     * Indicates if this "front-end" pseudo date is contained within a "front-end" use case.
096     * @return (boolean)handleIsContainedInFrontEndUseCase()
097     */
098    public final boolean isContainedInFrontEndUseCase()
099    {
100        boolean containedInFrontEndUseCase1a = this.__containedInFrontEndUseCase1a;
101        if (!this.__containedInFrontEndUseCase1aSet)
102        {
103            // containedInFrontEndUseCase has no pre constraints
104            containedInFrontEndUseCase1a = handleIsContainedInFrontEndUseCase();
105            // containedInFrontEndUseCase has no post constraints
106            this.__containedInFrontEndUseCase1a = containedInFrontEndUseCase1a;
107            if (isMetafacadePropertyCachingEnabled())
108            {
109                this.__containedInFrontEndUseCase1aSet = true;
110            }
111        }
112        return containedInFrontEndUseCase1a;
113    }
114
115    // ------------- associations ------------------
116
117    private List<FrontEndAction> __getContainerActions1r;
118    private boolean __getContainerActions1rSet = false;
119
120    /**
121     * Encapsulates a pseudostate and provides specific front-end services. This pseudostate can be
122     * a
123     * decision point, junction or initial state.
124     * @return (List<FrontEndAction>)handleGetContainerActions()
125     */
126    public final List<FrontEndAction> getContainerActions()
127    {
128        List<FrontEndAction> getContainerActions1r = this.__getContainerActions1r;
129        if (!this.__getContainerActions1rSet)
130        {
131            // frontEndPseudostate has no pre constraints
132            List result = handleGetContainerActions();
133            List shieldedResult = this.shieldedElements(result);
134            try
135            {
136                getContainerActions1r = (List<FrontEndAction>)shieldedResult;
137            }
138            catch (ClassCastException ex)
139            {
140                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
141                FrontEndPseudostateLogic.logger.warn("incorrect metafacade cast for FrontEndPseudostateLogic.getContainerActions List<FrontEndAction> " + result + ": " + shieldedResult);
142            }
143            // frontEndPseudostate has no post constraints
144            this.__getContainerActions1r = getContainerActions1r;
145            if (isMetafacadePropertyCachingEnabled())
146            {
147                this.__getContainerActions1rSet = true;
148            }
149        }
150        return getContainerActions1r;
151    }
152
153    /**
154     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
155     * @return  List
156     */
157    protected abstract List handleGetContainerActions();
158
159    /**
160     * @param validationMessages Collection<ModelValidationMessage>
161     * @see PseudostateFacadeLogicImpl#validateInvariants(Collection validationMessages)
162     */
163    @Override
164    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
165    {
166        super.validateInvariants(validationMessages);
167    }
168}