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 org.andromda.core.metafacade.MetafacadeBase;
009import org.andromda.core.metafacade.ModelValidationMessage;
010import org.andromda.metafacades.uml.GuardFacade;
011import org.andromda.metafacades.uml.TransitionFacade;
012import org.apache.log4j.Logger;
013import org.omg.uml.behavioralelements.statemachines.Guard;
014
015/**
016 * A representation of the model object 'Constraint'. A condition or restriction expressed in
017 * natural language text or in a machine readable language for the purpose of declaring some of the
018 * semantics of an element.
019 * MetafacadeLogic for GuardFacade
020 *
021 * @see GuardFacade
022 */
023public abstract class GuardFacadeLogic
024    extends ModelElementFacadeLogicImpl
025    implements GuardFacade
026{
027    /**
028     * The underlying UML object
029     * @see Guard
030     */
031    protected Guard metaObject;
032
033    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
034     * @param metaObjectIn
035     * @param context
036     */
037    protected GuardFacadeLogic(Guard metaObjectIn, String context)
038    {
039        super(metaObjectIn, getContext(context));
040        this.metaObject = metaObjectIn;
041    }
042
043    /**
044     * The logger instance.
045     */
046    private static final Logger logger = Logger.getLogger(GuardFacadeLogic.class);
047
048    /**
049     * Gets the context for this metafacade logic instance.
050     * @param context String. Set to GuardFacade if null
051     * @return context String
052     */
053    private static String getContext(String context)
054    {
055        if (context == null)
056        {
057            context = "org.andromda.metafacades.uml.GuardFacade";
058        }
059        return context;
060    }
061
062    /** Reset context only for non-root metafacades
063     * @param context
064     */
065    @Override
066    public void resetMetafacadeContext(String context)
067    {
068        if (!this.contextRoot) // reset context only for non-root metafacades
069        {
070            context = getContext(context);  // to have same value as in original constructor call
071            setMetafacadeContext (context);
072        }
073    }
074
075    /**
076     * @return boolean true always
077     * @see GuardFacade
078     */
079    public boolean isGuardFacadeMetaType()
080    {
081        return true;
082    }
083
084    // --------------- attributes ---------------------
085
086   /**
087    * @see GuardFacade#getBody()
088    * @return String
089    */
090    protected abstract String handleGetBody();
091
092    /**
093     * TODO: Model Documentation for GuardFacade.body
094     * @return (String)handleGetBody()
095     */
096    public final String getBody()
097    {
098        String body1a = null;
099        // 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}