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.InstanceValue;
06:
07: import java.util.ArrayList;
08: import java.util.Collection;
09:
10: /**
11: * MetafacadeLogic implementation for org.andromda.metafacades.uml.LinkEndFacade.
12: *
13: * @see org.andromda.metafacades.uml.LinkEndFacade
14: */
15: public class LinkEndFacadeLogicImpl extends LinkEndFacadeLogic {
16: public LinkEndFacadeLogicImpl(LinkEnd metaObject, String context) {
17: super (metaObject, context);
18: }
19:
20: /**
21: * @see org.andromda.metafacades.uml.LinkEndFacade#getInstance()
22: */
23: protected java.lang.Object handleGetInstance() {
24: final Collection values = this .getInstances();
25: return values.isEmpty() ? null : values.iterator().next();
26: }
27:
28: /**
29: * @see org.andromda.metafacades.uml.LinkEndFacade#getInstances()
30: */
31: protected java.util.Collection handleGetInstances() {
32: final Collection values = new ArrayList(this .metaObject
33: .getValues());
34:
35: CollectionUtils.transform(values, new Transformer() {
36: public Object transform(Object object) {
37: return UmlUtilities.ELEMENT_TRANSFORMER
38: .transform(((InstanceValue) object)
39: .getInstance());
40: }
41: });
42:
43: return values;
44: }
45:
46: /**
47: * @see org.andromda.metafacades.uml.LinkEndFacade#getAssociationEnd()
48: */
49: protected java.lang.Object handleGetAssociationEnd() {
50: return UmlUtilities.ELEMENT_TRANSFORMER
51: .transform(this .metaObject.getDefiningFeature());
52: }
53:
54: /**
55: * @see org.andromda.metafacades.uml.LinkEndFacade#getLink()
56: */
57: protected java.lang.Object handleGetLink() {
58: return UmlUtilities.ELEMENT_TRANSFORMER
59: .transform(this.metaObject.getOwner());
60: }
61: }
|