1 package org.andromda.metafacades.emf.uml22;
2
3 import java.util.List;
4 import org.apache.commons.lang.StringUtils;
5 import org.apache.log4j.Logger;
6 import org.eclipse.uml2.uml.DirectedRelationship;
7 import org.eclipse.uml2.uml.Element;
8
9
10
11
12
13
14
15 public class DependencyFacadeLogicImpl
16 extends DependencyFacadeLogic
17 {
18 private static final long serialVersionUID = 34L;
19
20
21
22
23 public DependencyFacadeLogicImpl(
24 final DirectedRelationship metaObject,
25 final String context)
26 {
27 super(metaObject, context);
28 }
29
30
31
32
33 private static final Logger LOGGER = Logger.getLogger(DependencyFacadeLogicImpl.class);
34
35
36
37
38
39
40
41
42
43
44
45 @Override
46 public String handleGetName()
47 {
48 String name = super.handleGetName();
49 if (StringUtils.isBlank(name) && this.getTargetElement() != null)
50 {
51 name = StringUtils.uncapitalize(this.getTargetElement().getName());
52 }
53 return name;
54 }
55
56
57
58
59 @Override
60 protected String handleGetGetterName()
61 {
62 return "get" + StringUtils.capitalize(this.handleGetName());
63 }
64
65
66
67
68 @Override
69 protected String handleGetSetterName()
70 {
71 return "set" + StringUtils.capitalize(this.handleGetName());
72 }
73
74
75
76
77 @Override
78 protected Object handleGetTargetElement()
79 {
80 Object transform = null;
81 final List<Element> elist = this.metaObject.getTargets();
82 if (elist == null || elist.isEmpty())
83 {
84 DependencyFacadeLogicImpl.LOGGER.error("DependencyFacade has no targets: " + this.metaObject.getSources().toString());
85 }
86 else
87 {
88 transform = UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getTargets().toArray()[0]);
89 }
90 return transform;
91 }
92
93
94
95
96 @Override
97 protected Object handleGetSourceElement()
98 {
99 return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getSources().toArray()[0]);
100 }
101 }