01: package org.andromda.metafacades.uml14;
02:
03: import org.apache.commons.lang.StringUtils;
04:
05: import java.util.Collection;
06:
07: /**
08: * Metaclass facade implementation.
09: */
10: public class DependencyFacadeLogicImpl extends DependencyFacadeLogic {
11: public DependencyFacadeLogicImpl(
12: org.omg.uml.foundation.core.Dependency metaObject,
13: String context) {
14: super (metaObject, context);
15: }
16:
17: /**
18: * Gets the name in the following manner. <ol> <li>If the dependency has a name return it.</li> <li>If the
19: * dependency does <strong>NOT </strong> have a name, get the target element's and return its name
20: * uncapitalized.</li> </ol>
21: *
22: * @see org.andromda.metafacades.uml.ModelElementFacade#getName()
23: */
24: public String handleGetName() {
25: String name = super .handleGetName();
26: if (StringUtils.isBlank(name)
27: && this .getTargetElement() != null) {
28: name = StringUtils.uncapitalize(this .getTargetElement()
29: .getName());
30: }
31: return name;
32: }
33:
34: /**
35: * @see org.andromda.metafacades.uml.DependencyFacade#getGetterName()
36: */
37: public java.lang.String handleGetGetterName() {
38: return "get" + StringUtils.capitalize(this .getName());
39: }
40:
41: /**
42: * @see org.andromda.metafacades.uml.DependencyFacade#getSetterName()
43: */
44: public java.lang.String handleGetSetterName() {
45: return "set" + StringUtils.capitalize(this .getName());
46: }
47:
48: /**
49: * @see org.andromda.metafacades.uml.DependencyFacade#getTargetElement()
50: */
51: public Object handleGetTargetElement() {
52: Object targetElement = null;
53: Collection suppliers = UML14MetafacadeUtils.getCorePackage()
54: .getASupplierSupplierDependency().getSupplier(
55: this .metaObject);
56: if (!suppliers.isEmpty()) {
57: targetElement = suppliers.iterator().next();
58: }
59: return targetElement;
60: }
61:
62: /**
63: * @see org.andromda.metafacades.uml.DependencyFacade#getSourceElement()
64: */
65: protected Object handleGetSourceElement() {
66: Object sourceElement = null;
67: Collection clients = UML14MetafacadeUtils.getCorePackage()
68: .getAClientClientDependency()
69: .getClient(this.metaObject);
70: if (!clients.isEmpty()) {
71: sourceElement = clients.iterator().next();
72: }
73: return sourceElement;
74: }
75:
76: }
|