01: package org.andromda.metafacades.uml14;
02:
03: import org.andromda.metafacades.uml.AssociationEndFacade;
04: import org.andromda.metafacades.uml.MetafacadeUtils;
05: import org.andromda.metafacades.uml.UMLMetafacadeProperties;
06: import org.apache.commons.lang.StringUtils;
07: import org.omg.uml.foundation.core.AssociationClass;
08:
09: /**
10: * Metaclass facade implementation.
11: */
12: public class AssociationFacadeLogicImpl extends AssociationFacadeLogic
13: implements org.andromda.metafacades.uml.AssociationFacade {
14: public AssociationFacadeLogicImpl(
15: org.omg.uml.foundation.core.UmlAssociation metaObject,
16: String context) {
17: super (metaObject, context);
18: }
19:
20: /**
21: * @see org.andromda.metafacades.uml.AssociationFacade#getAssociationEnds()
22: */
23: public java.util.List handleGetAssociationEnds() {
24: return metaObject.getConnection();
25: }
26:
27: /**
28: * @see org.andromda.metafacades.uml14.ModelElementFacadeLogic#handleGetName()
29: */
30: public String handleGetName() {
31: String name = super .handleGetName();
32:
33: // if the name isn't defined, use the relation name
34: if (StringUtils.isEmpty(name)) {
35: name = this .getRelationName();
36: }
37: return name;
38: }
39:
40: /**
41: * @see org.andromda.metafacades.uml.AssociationFacade#getRelationName()
42: */
43: public String handleGetRelationName() {
44: final AssociationEndFacade firstEnd = this .getAssociationEndA();
45: final AssociationEndFacade secondEnd = this
46: .getAssociationEndB();
47: return MetafacadeUtils
48: .toRelationName(
49: firstEnd.getName(),
50: secondEnd.getName(),
51: String
52: .valueOf(this
53: .getConfiguredProperty(UMLMetafacadeProperties.RELATION_NAME_SEPARATOR)));
54: }
55:
56: /**
57: * @see org.andromda.metafacades.uml.AssociationFacade#isMany2Many()
58: */
59: protected boolean handleIsMany2Many() {
60: return ((AssociationEndFacade) this .getAssociationEnds()
61: .iterator().next()).isMany2Many();
62: }
63:
64: /**
65: * @see org.andromda.metafacades.uml.AssociationFacade#isAssociationClass()
66: */
67: protected boolean handleIsAssociationClass() {
68: return AssociationClass.class.isAssignableFrom(this .metaObject
69: .getClass());
70: }
71:
72: /**
73: * @see org.andromda.metafacades.uml.AssociationFacade#getAssociationEndA()
74: */
75: protected Object handleGetAssociationEndA() {
76: return this .getAssociationEnds().get(0);
77: }
78:
79: /**
80: * @see org.andromda.metafacades.uml.AssociationFacade#getAssociationEndB()
81: */
82: protected Object handleGetAssociationEndB() {
83: return this .getAssociationEnds().get(1);
84: }
85:
86: /**
87: * @see org.andromda.metafacades.uml.AssociationFacade#isAbstract()
88: */
89: protected boolean handleIsAbstract() {
90: return this .metaObject.isAbstract();
91: }
92:
93: /**
94: * @see org.andromda.metafacades.uml.AssociationFacade#isLeaf
95: */
96: protected boolean handleIsLeaf() {
97: return this.metaObject.isLeaf();
98: }
99: }
|