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.ValueSpecification;
9   
10  
11  /**
12   * MetafacadeLogic implementation for org.andromda.metafacades.uml.AttributeLinkFacade.
13   *
14   * @see org.andromda.metafacades.uml.AttributeLinkFacade
15   */
16  public class AttributeLinkFacadeLogicImpl
17      extends AttributeLinkFacadeLogic
18  {
19      private static final long serialVersionUID = 34L;
20      /**
21       * @param metaObject
22       * @param context
23       * @see org.andromda.metafacades.uml.AttributeLinkFacade
24       */
25      public AttributeLinkFacadeLogicImpl(final AttributeLink metaObject, final String context)
26      {
27          super(metaObject, context);
28      }
29  
30      /**
31       * @see org.andromda.metafacades.uml.AttributeLinkFacade#getAttribute()
32       */
33      @Override
34      protected Object handleGetAttribute()
35      {
36          return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getDefiningFeature());
37      }
38  
39      /**
40       * @see org.andromda.metafacades.uml.AttributeLinkFacade#getInstance()
41       */
42      @Override
43      protected Object handleGetInstance()
44      {
45          return UmlUtilities.ELEMENT_TRANSFORMER.transform(this.metaObject.getOwningInstance());
46      }
47  
48      /**
49       * @see org.andromda.metafacades.uml.AttributeLinkFacade#getValue()
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       * @see org.andromda.metafacades.uml.AttributeLinkFacade#getValues()
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  }