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.GeneralizableElementFacade;
011import org.andromda.metafacades.uml.GeneralizationFacade;
012import org.apache.log4j.Logger;
013import org.omg.uml.foundation.core.Generalization;
014
015/**
016 * A taxonomic relationship between a more general classifier and a more specific classifier. Each
017 * instance of the specific classifier is also an indirect instance of the general classifier. Thus,
018 * the specific classifier inherits the features of the more general classifier. A generalization
019 * relates a specific classifier to a more general classifier, and is owned by the specific
020 * classifier.
021 * MetafacadeLogic for GeneralizationFacade
022 *
023 * @see GeneralizationFacade
024 */
025public abstract class GeneralizationFacadeLogic
026    extends ModelElementFacadeLogicImpl
027    implements GeneralizationFacade
028{
029    /**
030     * The underlying UML object
031     * @see Generalization
032     */
033    protected Generalization metaObject;
034
035    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
036     * @param metaObjectIn
037     * @param context
038     */
039    protected GeneralizationFacadeLogic(Generalization metaObjectIn, String context)
040    {
041        super(metaObjectIn, getContext(context));
042        this.metaObject = metaObjectIn;
043    }
044
045    /**
046     * The logger instance.
047     */
048    private static final Logger logger = Logger.getLogger(GeneralizationFacadeLogic.class);
049
050    /**
051     * Gets the context for this metafacade logic instance.
052     * @param context String. Set to GeneralizationFacade if null
053     * @return context String
054     */
055    private static String getContext(String context)
056    {
057        if (context == null)
058        {
059            context = "org.andromda.metafacades.uml.GeneralizationFacade";
060        }
061        return context;
062    }
063
064    /** Reset context only for non-root metafacades
065     * @param context
066     */
067    @Override
068    public void resetMetafacadeContext(String context)
069    {
070        if (!this.contextRoot) // reset context only for non-root metafacades
071        {
072            context = getContext(context);  // to have same value as in original constructor call
073            setMetafacadeContext (context);
074        }
075    }
076
077    /**
078     * @return boolean true always
079     * @see GeneralizationFacade
080     */
081    public boolean isGeneralizationFacadeMetaType()
082    {
083        return true;
084    }
085
086    // ------------- associations ------------------
087
088    /**
089     * A taxonomic relationship between a more general classifier and a more specific classifier.
090     * Each
091     * instance of the specific classifier is also an indirect instance of the general classifier.
092     * Thus,
093     * the specific classifier inherits the features of the more general classifier. A
094     * generalization
095     * relates a specific classifier to a more general classifier, and is owned by the specific
096     * classifier.
097     * @return (GeneralizableElementFacade)handleGetParent()
098     */
099    public final GeneralizableElementFacade getParent()
100    {
101        GeneralizableElementFacade getParent1r = null;
102        // generalizationFacade has no pre constraints
103        Object result = handleGetParent();
104        MetafacadeBase shieldedResult = this.shieldedElement(result);
105        try
106        {
107            getParent1r = (GeneralizableElementFacade)shieldedResult;
108        }
109        catch (ClassCastException ex)
110        {
111            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
112            GeneralizationFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizationFacadeLogic.getParent GeneralizableElementFacade " + result + ": " + shieldedResult);
113        }
114        // generalizationFacade has no post constraints
115        return getParent1r;
116    }
117
118    /**
119     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
120     * @return Object
121     */
122    protected abstract Object handleGetParent();
123
124    /**
125     * A taxonomic relationship between a more general classifier and a more specific classifier.
126     * Each
127     * instance of the specific classifier is also an indirect instance of the general classifier.
128     * Thus,
129     * the specific classifier inherits the features of the more general classifier. A
130     * generalization
131     * relates a specific classifier to a more general classifier, and is owned by the specific
132     * classifier.
133     * @return (GeneralizableElementFacade)handleGetChild()
134     */
135    public final GeneralizableElementFacade getChild()
136    {
137        GeneralizableElementFacade getChild2r = null;
138        // generalizationFacade has no pre constraints
139        Object result = handleGetChild();
140        MetafacadeBase shieldedResult = this.shieldedElement(result);
141        try
142        {
143            getChild2r = (GeneralizableElementFacade)shieldedResult;
144        }
145        catch (ClassCastException ex)
146        {
147            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
148            GeneralizationFacadeLogic.logger.warn("incorrect metafacade cast for GeneralizationFacadeLogic.getChild GeneralizableElementFacade " + result + ": " + shieldedResult);
149        }
150        // generalizationFacade has no post constraints
151        return getChild2r;
152    }
153
154    /**
155     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
156     * @return Object
157     */
158    protected abstract Object handleGetChild();
159
160    /**
161     * @param validationMessages Collection<ModelValidationMessage>
162     * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
163     */
164    @Override
165    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
166    {
167        super.validateInvariants(validationMessages);
168    }
169}