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.AssociationEndFacade;
012import org.andromda.metafacades.uml.AssociationFacade;
013import org.apache.log4j.Logger;
014import org.omg.uml.foundation.core.UmlAssociation;
015
016/**
017 * An association describes a set of tuples whose values refer to typed instances. An instance of an
018 * association is called a link.
019 * MetafacadeLogic for AssociationFacade
020 *
021 * @see AssociationFacade
022 */
023public abstract class AssociationFacadeLogic
024    extends GeneralizableElementFacadeLogicImpl
025    implements AssociationFacade
026{
027    /**
028     * The underlying UML object
029     * @see UmlAssociation
030     */
031    protected UmlAssociation metaObject;
032
033    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
034     * @param metaObjectIn
035     * @param context
036     */
037    protected AssociationFacadeLogic(UmlAssociation 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(AssociationFacadeLogic.class);
047
048    /**
049     * Gets the context for this metafacade logic instance.
050     * @param context String. Set to AssociationFacade 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.AssociationFacade";
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 AssociationFacade
078     */
079    public boolean isAssociationFacadeMetaType()
080    {
081        return true;
082    }
083
084    // --------------- attributes ---------------------
085
086   /**
087    * @see AssociationFacade#getRelationName()
088    * @return String
089    */
090    protected abstract String handleGetRelationName();
091
092    private String __relationName1a;
093    private boolean __relationName1aSet = false;
094
095    /**
096     * A name suited for naming this relationship. This name will be constructed from both
097     * association ends.
098     * @return (String)handleGetRelationName()
099     */
100    public final String getRelationName()
101    {
102        String relationName1a = this.__relationName1a;
103        if (!this.__relationName1aSet)
104        {
105            // relationName has no pre constraints
106            relationName1a = handleGetRelationName();
107            // relationName has no post constraints
108            this.__relationName1a = relationName1a;
109            if (isMetafacadePropertyCachingEnabled())
110            {
111                this.__relationName1aSet = true;
112            }
113        }
114        return relationName1a;
115    }
116
117   /**
118    * @see AssociationFacade#isMany2Many()
119    * @return boolean
120    */
121    protected abstract boolean handleIsMany2Many();
122
123    private boolean __many2Many2a;
124    private boolean __many2Many2aSet = false;
125
126    /**
127     * Indicates whether or not this associations represents a many-to-many relation.
128     * @return (boolean)handleIsMany2Many()
129     */
130    public final boolean isMany2Many()
131    {
132        boolean many2Many2a = this.__many2Many2a;
133        if (!this.__many2Many2aSet)
134        {
135            // many2Many has no pre constraints
136            many2Many2a = handleIsMany2Many();
137            // many2Many has no post constraints
138            this.__many2Many2a = many2Many2a;
139            if (isMetafacadePropertyCachingEnabled())
140            {
141                this.__many2Many2aSet = true;
142            }
143        }
144        return many2Many2a;
145    }
146
147   /**
148    * @see AssociationFacade#isAssociationClass()
149    * @return boolean
150    */
151    protected abstract boolean handleIsAssociationClass();
152
153    private boolean __associationClass3a;
154    private boolean __associationClass3aSet = false;
155
156    /**
157     * True if the AssociationFacade is an AssociationClass.
158     * @return (boolean)handleIsAssociationClass()
159     */
160    public final boolean isAssociationClass()
161    {
162        boolean associationClass3a = this.__associationClass3a;
163        if (!this.__associationClass3aSet)
164        {
165            // associationClass has no pre constraints
166            associationClass3a = handleIsAssociationClass();
167            // associationClass has no post constraints
168            this.__associationClass3a = associationClass3a;
169            if (isMetafacadePropertyCachingEnabled())
170            {
171                this.__associationClass3aSet = true;
172            }
173        }
174        return associationClass3a;
175    }
176
177   /**
178    * @see AssociationFacade#isAbstract()
179    * @return boolean
180    */
181    protected abstract boolean handleIsAbstract();
182
183    private boolean __abstract4a;
184    private boolean __abstract4aSet = false;
185
186    /**
187     * Indicates if this association is 'abstract'.
188     * @return (boolean)handleIsAbstract()
189     */
190    public final boolean isAbstract()
191    {
192        boolean abstract4a = this.__abstract4a;
193        if (!this.__abstract4aSet)
194        {
195            // abstract has no pre constraints
196            abstract4a = handleIsAbstract();
197            // abstract has no post constraints
198            this.__abstract4a = abstract4a;
199            if (isMetafacadePropertyCachingEnabled())
200            {
201                this.__abstract4aSet = true;
202            }
203        }
204        return abstract4a;
205    }
206
207   /**
208    * @see AssociationFacade#isLeaf()
209    * @return boolean
210    */
211    protected abstract boolean handleIsLeaf();
212
213    private boolean __leaf5a;
214    private boolean __leaf5aSet = false;
215
216    /**
217     * True if this association cannot be extended and represent a leaf in the inheritance tree.
218     * @return (boolean)handleIsLeaf()
219     */
220    public final boolean isLeaf()
221    {
222        boolean leaf5a = this.__leaf5a;
223        if (!this.__leaf5aSet)
224        {
225            // leaf has no pre constraints
226            leaf5a = handleIsLeaf();
227            // leaf has no post constraints
228            this.__leaf5a = leaf5a;
229            if (isMetafacadePropertyCachingEnabled())
230            {
231                this.__leaf5aSet = true;
232            }
233        }
234        return leaf5a;
235    }
236
237   /**
238    * @see AssociationFacade#isDerived()
239    * @return boolean
240    */
241    protected abstract boolean handleIsDerived();
242
243    private boolean __derived6a;
244    private boolean __derived6aSet = false;
245
246    /**
247     * UML2: Returns the value of the 'Is Derived' attribute. The default value is "false". If
248     * isDerived is true, the value of the attribute is derived from information elsewhere.
249     * Specifies whether the Property is derived, i.e., whether its value or values can be computed
250     * from other information.
251     * @return (boolean)handleIsDerived()
252     */
253    public final boolean isDerived()
254    {
255        boolean derived6a = this.__derived6a;
256        if (!this.__derived6aSet)
257        {
258            // derived has no pre constraints
259            derived6a = handleIsDerived();
260            // derived has no post constraints
261            this.__derived6a = derived6a;
262            if (isMetafacadePropertyCachingEnabled())
263            {
264                this.__derived6aSet = true;
265            }
266        }
267        return derived6a;
268    }
269
270   /**
271    * @see AssociationFacade#isBinary()
272    * @return boolean
273    */
274    protected abstract boolean handleIsBinary();
275
276    private boolean __binary7a;
277    private boolean __binary7aSet = false;
278
279    /**
280     * UML2: Determines whether this association is a binary association, i.e. whether it has
281     * exactly two member ends. UML2 allows association classes in the association itself (many2many
282     * with association attributes). Default=true: only two member ends.
283     * @return (boolean)handleIsBinary()
284     */
285    public final boolean isBinary()
286    {
287        boolean binary7a = this.__binary7a;
288        if (!this.__binary7aSet)
289        {
290            // binary has no pre constraints
291            binary7a = handleIsBinary();
292            // binary has no post constraints
293            this.__binary7a = binary7a;
294            if (isMetafacadePropertyCachingEnabled())
295            {
296                this.__binary7aSet = true;
297            }
298        }
299        return binary7a;
300    }
301
302    // ------------- associations ------------------
303
304    /**
305     * The association owning this association end.
306     * @return (List<AssociationEndFacade>)handleGetAssociationEnds()
307     */
308    public final List<AssociationEndFacade> getAssociationEnds()
309    {
310        List<AssociationEndFacade> getAssociationEnds1r = null;
311        // association has no pre constraints
312        List result = handleGetAssociationEnds();
313        List shieldedResult = this.shieldedElements(result);
314        try
315        {
316            getAssociationEnds1r = (List<AssociationEndFacade>)shieldedResult;
317        }
318        catch (ClassCastException ex)
319        {
320            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
321            AssociationFacadeLogic.logger.warn("incorrect metafacade cast for AssociationFacadeLogic.getAssociationEnds List<AssociationEndFacade> " + result + ": " + shieldedResult);
322        }
323        // association has no post constraints
324        return getAssociationEnds1r;
325    }
326
327    /**
328     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
329     * @return  List
330     */
331    protected abstract List handleGetAssociationEnds();
332
333    private AssociationEndFacade __getAssociationEndA2r;
334    private boolean __getAssociationEndA2rSet = false;
335
336    /**
337     * An association describes a set of tuples whose values refer to typed instances. An instance
338     * of an
339     * association is called a link.
340     * @return (AssociationEndFacade)handleGetAssociationEndA()
341     */
342    public final AssociationEndFacade getAssociationEndA()
343    {
344        AssociationEndFacade getAssociationEndA2r = this.__getAssociationEndA2r;
345        if (!this.__getAssociationEndA2rSet)
346        {
347            // associationFacade has no pre constraints
348            Object result = handleGetAssociationEndA();
349            MetafacadeBase shieldedResult = this.shieldedElement(result);
350            try
351            {
352                getAssociationEndA2r = (AssociationEndFacade)shieldedResult;
353            }
354            catch (ClassCastException ex)
355            {
356                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
357                AssociationFacadeLogic.logger.warn("incorrect metafacade cast for AssociationFacadeLogic.getAssociationEndA AssociationEndFacade " + result + ": " + shieldedResult);
358            }
359            // associationFacade has no post constraints
360            this.__getAssociationEndA2r = getAssociationEndA2r;
361            if (isMetafacadePropertyCachingEnabled())
362            {
363                this.__getAssociationEndA2rSet = true;
364            }
365        }
366        return getAssociationEndA2r;
367    }
368
369    /**
370     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
371     * @return Object
372     */
373    protected abstract Object handleGetAssociationEndA();
374
375    private AssociationEndFacade __getAssociationEndB3r;
376    private boolean __getAssociationEndB3rSet = false;
377
378    /**
379     * An association describes a set of tuples whose values refer to typed instances. An instance
380     * of an
381     * association is called a link.
382     * @return (AssociationEndFacade)handleGetAssociationEndB()
383     */
384    public final AssociationEndFacade getAssociationEndB()
385    {
386        AssociationEndFacade getAssociationEndB3r = this.__getAssociationEndB3r;
387        if (!this.__getAssociationEndB3rSet)
388        {
389            // associationFacade has no pre constraints
390            Object result = handleGetAssociationEndB();
391            MetafacadeBase shieldedResult = this.shieldedElement(result);
392            try
393            {
394                getAssociationEndB3r = (AssociationEndFacade)shieldedResult;
395            }
396            catch (ClassCastException ex)
397            {
398                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
399                AssociationFacadeLogic.logger.warn("incorrect metafacade cast for AssociationFacadeLogic.getAssociationEndB AssociationEndFacade " + result + ": " + shieldedResult);
400            }
401            // associationFacade has no post constraints
402            this.__getAssociationEndB3r = getAssociationEndB3r;
403            if (isMetafacadePropertyCachingEnabled())
404            {
405                this.__getAssociationEndB3rSet = true;
406            }
407        }
408        return getAssociationEndB3r;
409    }
410
411    /**
412     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
413     * @return Object
414     */
415    protected abstract Object handleGetAssociationEndB();
416
417    /**
418     * @param validationMessages Collection<ModelValidationMessage>
419     * @see GeneralizableElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
420     */
421    @Override
422    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
423    {
424        super.validateInvariants(validationMessages);
425    }
426}