View Javadoc
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.InstanceValue;
9   import org.eclipse.uml2.uml.ValueSpecification;
10  
11  /**
12   * MetafacadeLogic implementation for org.andromda.metafacades.uml.LinkEndFacade.
13   *
14   * @see org.andromda.metafacades.uml.LinkEndFacade
15   */
16  public class LinkEndFacadeLogicImpl extends LinkEndFacadeLogic
17  {
18      private static final long serialVersionUID = 7536864323808174017L;
19  
20      /**
21       * @param metaObject
22       * @param context
23       */
24      public LinkEndFacadeLogicImpl(final LinkEnd metaObject, final String context)
25      {
26          super(metaObject, context);
27      }
28  
29      /**
30       * @see org.andromda.metafacades.uml.LinkEndFacade#getInstance()
31       */
32      @Override
33      protected InstanceFacade handleGetInstance()
34      {
35          final Collection<InstanceFacade> values = this.getInstances();
36          return (values.isEmpty() ? null : values.iterator().next());
37      }
38  
39      /**
40       * @see org.andromda.metafacades.uml.LinkEndFacade#getInstances()
41       */
42      @Override
43      protected Collection<InstanceValue> handleGetInstances()
44      {
45          final Collection values = new ArrayList<ValueSpecification>(this.metaObject.getValues());
46  
47          CollectionUtils.transform(values, new Transformer()
48          {
49              public Object transform(final Object object)
50              {
51                  return UmlUtilities.ELEMENT_TRANSFORMER.transform(((InstanceValue)object).getInstance());
52              }
53          });
54  
55          return values;
56      }
57  
58      /**
59       * @see org.andromda.metafacades.uml.LinkEndFacade#getAssociationEnd()
60       */
61      @Override
62      protected Object handleGetAssociationEnd()
63      {
64          return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getDefiningFeature());
65      }
66  
67      /**
68       * @see org.andromda.metafacades.uml.LinkEndFacade#getLink()
69       */
70      @Override
71      protected Object handleGetLink()
72      {
73          return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getOwner());
74      }
75  }