1 package org.andromda.metafacades.emf.uml22;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import org.andromda.metafacades.uml.InstanceFacade;
6 import org.apache.commons.collections.CollectionUtils;
7 import org.apache.commons.collections.Transformer;
8 import org.eclipse.uml2.uml.ValueSpecification;
9
10
11
12
13
14
15
16 public class AttributeLinkFacadeLogicImpl
17 extends AttributeLinkFacadeLogic
18 {
19 private static final long serialVersionUID = 34L;
20
21
22
23
24
25 public AttributeLinkFacadeLogicImpl(final AttributeLink metaObject, final String context)
26 {
27 super(metaObject, context);
28 }
29
30
31
32
33 @Override
34 protected Object handleGetAttribute()
35 {
36 return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getDefiningFeature());
37 }
38
39
40
41
42 @Override
43 protected Object handleGetInstance()
44 {
45 return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getOwningInstance());
46 }
47
48
49
50
51 @Override
52 protected InstanceFacade handleGetValue()
53 {
54 final Collection<InstanceFacade> values = this.getValues();
55 return values.isEmpty() ? null : values.iterator().next();
56 }
57
58
59
60
61 @Override
62 protected Collection<ValueSpecification> handleGetValues()
63 {
64 final Collection<ValueSpecification> values = new ArrayList<ValueSpecification>(this.metaObject.getValues());
65
66 CollectionUtils.transform(values, new Transformer()
67 {
68 public Object transform(final Object object)
69 {
70 return InstanceFacadeLogicImpl.createInstanceFor((ValueSpecification)object);
71 }
72 });
73
74 return values;
75 }
76 }