01: package org.andromda.metafacades.emf.uml2;
02:
03: import org.apache.commons.collections.CollectionUtils;
04: import org.apache.commons.collections.Transformer;
05: import org.eclipse.uml2.ValueSpecification;
06:
07: import java.util.ArrayList;
08: import java.util.Collection;
09:
10: /**
11: * MetafacadeLogic implementation for org.andromda.metafacades.uml.AttributeLinkFacade.
12: *
13: * @see org.andromda.metafacades.uml.AttributeLinkFacade
14: */
15: public class AttributeLinkFacadeLogicImpl extends
16: AttributeLinkFacadeLogic {
17: public AttributeLinkFacadeLogicImpl(AttributeLink metaObject,
18: String context) {
19: super (metaObject, context);
20: }
21:
22: /**
23: * @see org.andromda.metafacades.uml.AttributeLinkFacade#getAttribute()
24: */
25: protected java.lang.Object handleGetAttribute() {
26: return UmlUtilities.ELEMENT_TRANSFORMER
27: .transform(this .metaObject.getDefiningFeature());
28: }
29:
30: /**
31: * @see org.andromda.metafacades.uml.AttributeLinkFacade#getInstance()
32: */
33: protected java.lang.Object handleGetInstance() {
34: return UmlUtilities.ELEMENT_TRANSFORMER
35: .transform(this .metaObject.getOwningInstance());
36: }
37:
38: /**
39: * @see org.andromda.metafacades.uml.AttributeLinkFacade#getValue()
40: */
41: protected java.lang.Object handleGetValue() {
42: final Collection values = this .getValues();
43: return values.isEmpty() ? null : values.iterator().next();
44: }
45:
46: /**
47: * @see org.andromda.metafacades.uml.AttributeLinkFacade#getValues()
48: */
49: protected Collection handleGetValues() {
50: final Collection values = new ArrayList(this .metaObject
51: .getValues());
52:
53: CollectionUtils.transform(values, new Transformer() {
54: public Object transform(Object object) {
55: return InstanceFacadeLogicImpl
56: .createInstanceFor((ValueSpecification) object);
57: }
58: });
59:
60: return values;
61: }
62: }
|