View Javadoc
1   package org.andromda.metafacades.emf.uml22;
2   
3   import java.lang.reflect.InvocationTargetException;
4   import java.util.Map;
5   import org.eclipse.emf.common.notify.Adapter;
6   import org.eclipse.emf.common.notify.Notification;
7   import org.eclipse.emf.common.util.DiagnosticChain;
8   import org.eclipse.emf.common.util.EList;
9   import org.eclipse.emf.common.util.TreeIterator;
10  import org.eclipse.emf.ecore.EAnnotation;
11  import org.eclipse.emf.ecore.EClass;
12  import org.eclipse.emf.ecore.EObject;
13  import org.eclipse.emf.ecore.EOperation;
14  import org.eclipse.emf.ecore.EReference;
15  import org.eclipse.emf.ecore.EStructuralFeature;
16  import org.eclipse.emf.ecore.resource.Resource;
17  import org.eclipse.uml2.uml.Comment;
18  import org.eclipse.uml2.uml.DirectedRelationship;
19  import org.eclipse.uml2.uml.Element;
20  import org.eclipse.uml2.uml.InstanceSpecification;
21  import org.eclipse.uml2.uml.Model;
22  import org.eclipse.uml2.uml.Package;
23  import org.eclipse.uml2.uml.Relationship;
24  import org.eclipse.uml2.uml.Slot;
25  import org.eclipse.uml2.uml.Stereotype;
26  import org.eclipse.uml2.uml.StructuralFeature;
27  import org.eclipse.uml2.uml.Type;
28  import org.eclipse.uml2.uml.ValueSpecification;
29  
30  /**
31   * Implementation of AttributeLink.
32   *
33   * We extend Slot. We keep a reference to the original slot and we defer
34   * almost all method calls to it.
35   *
36   * @author Wouter Zoons
37   */
38  public class AttributeLinkImpl implements AttributeLink
39  {
40      /**
41       *
42       */
43      final Slot slot;
44  
45      /**
46       * @param slotIn
47       */
48      AttributeLinkImpl(final Slot slotIn)
49      {
50          this.slot = slotIn;
51      }
52  
53      /**
54       * @see Object#equals(Object)
55       */
56      @Override
57      public boolean equals(final Object object)
58      {
59          if (object instanceof AttributeLinkImpl)
60          {
61              return this.slot.equals(((AttributeLinkImpl)object).slot);
62          }
63          /*if (object instanceof LinkEndImpl)
64          {
65              return this.slot.equals(((LinkEndImpl)object).slot);
66          }*/
67          return this.slot.equals(object);
68      }
69  
70      /**
71       * @see Object#hashCode()
72       */
73      @Override
74      public int hashCode()
75      {
76          return this.slot.hashCode();
77      }
78  
79      /**
80       * @see Object#toString()
81       */
82      @Override
83      public String toString()
84      {
85          return this.getClass().getName() + '[' + this.slot.toString() + ']';
86      }
87  
88      /**
89       * @see org.eclipse.uml2.uml.Slot#getOwningInstance()
90       */
91      public InstanceSpecification getOwningInstance()
92      {
93          return this.slot.getOwningInstance();
94      }
95  
96      /**
97       * @see org.eclipse.uml2.uml.Slot#setOwningInstance(org.eclipse.uml2.uml.InstanceSpecification)
98       */
99      public void setOwningInstance(final InstanceSpecification instanceSpecification)
100     {
101         this.slot.setOwningInstance(instanceSpecification);
102     }
103 
104     /**
105      * @see org.eclipse.uml2.uml.Slot#getValues()
106      */
107     public EList<ValueSpecification> getValues()
108     {
109         return this.slot.getValues();
110     }
111 
112     /**
113      * @param string
114      * @return slot.getValue(string, null)
115      */
116     public ValueSpecification getValue(final String string)
117     {
118         return this.slot.getValue(string, null);
119     }
120 
121     /**
122      * @see org.eclipse.uml2.uml.Slot#getValue(String, org.eclipse.uml2.uml.Type)
123      */
124     public ValueSpecification getValue(final String string, final Type type)
125     {
126         return this.slot.getValue(string, type);
127     }
128 
129     /**
130      * @see org.eclipse.uml2.uml.Slot#getValue(String, org.eclipse.uml2.uml.Type, boolean, org.eclipse.emf.ecore.EClass, boolean)
131      */
132     public ValueSpecification getValue(final String name, final Type type, final boolean ignoreCase, final EClass eClass, final boolean createOnDemand)
133     {
134         return this.slot.getValue(name, type, ignoreCase, eClass, createOnDemand);
135     }
136 
137     /**
138      * @param eClass
139      * @return slot.createValue(null, null, eClass)
140      */
141     public ValueSpecification createValue(final EClass eClass)
142     {
143         return this.slot.createValue(null, null, eClass);
144     }
145 
146     /**
147      * @see org.eclipse.uml2.uml.Slot#createValue(String, org.eclipse.uml2.uml.Type, org.eclipse.emf.ecore.EClass)
148      */
149     public ValueSpecification createValue(final String name, final Type type, final EClass eClass)
150     {
151         return this.slot.createValue(name, type, eClass);
152     }
153 
154     /**
155      * @see org.eclipse.uml2.uml.Slot#getDefiningFeature()
156      */
157     public StructuralFeature getDefiningFeature()
158     {
159         return this.slot.getDefiningFeature();
160     }
161 
162     /**
163      * @see org.eclipse.uml2.uml.Slot#setDefiningFeature(org.eclipse.uml2.uml.StructuralFeature)
164      */
165     public void setDefiningFeature(final StructuralFeature structuralFeature)
166     {
167         this.slot.setDefiningFeature(structuralFeature);
168     }
169 
170     /**
171      * @see org.eclipse.emf.ecore.EObject#eGet(org.eclipse.emf.ecore.EStructuralFeature, boolean)
172      */
173     public Object eGet(final EStructuralFeature eStructuralFeature, final boolean resolve)
174     {
175         return this.slot.eGet(eStructuralFeature, resolve);
176     }
177 
178     /**
179      * @see org.eclipse.emf.ecore.EObject#eSet(org.eclipse.emf.ecore.EStructuralFeature, Object)
180      */
181     public void eSet(final EStructuralFeature eStructuralFeature, final Object object)
182     {
183         this.slot.eSet(eStructuralFeature, object);
184     }
185 
186     /**
187      * @see org.eclipse.emf.ecore.EObject#eUnset(org.eclipse.emf.ecore.EStructuralFeature)
188      */
189     public void eUnset(final EStructuralFeature eStructuralFeature)
190     {
191         this.slot.eUnset(eStructuralFeature);
192     }
193 
194     /**
195      * @see org.eclipse.emf.ecore.EObject#eIsSet(org.eclipse.emf.ecore.EStructuralFeature)
196      */
197     public boolean eIsSet(final EStructuralFeature eStructuralFeature)
198     {
199         return this.slot.eIsSet(eStructuralFeature);
200     }
201 
202     /**
203      * @see org.eclipse.uml2.uml.Element#getOwnedElements()
204      */
205     public EList<Element> getOwnedElements()
206     {
207         return this.slot.getOwnedElements();
208     }
209 
210     /**
211      * @see org.eclipse.uml2.uml.Element#getOwner()
212      */
213     public Element getOwner()
214     {
215         return this.slot.getOwner();
216     }
217 
218     /**
219      * @see org.eclipse.uml2.uml.Element#getOwnedComments()
220      */
221     public EList<Comment> getOwnedComments()
222     {
223         return this.slot.getOwnedComments();
224     }
225 
226     /**
227      * @param eClass
228      * @return slot.createOwnedComment()
229      */
230     public Comment createOwnedComment(final EClass eClass)
231     {
232         return this.slot.createOwnedComment();
233     }
234 
235     /**
236      * @see org.eclipse.uml2.uml.Element#createOwnedComment()
237      */
238     public Comment createOwnedComment()
239     {
240         return this.slot.createOwnedComment();
241     }
242 
243     /**
244      * @see org.eclipse.uml2.uml.Element#validateHasOwner(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
245      */
246     public boolean validateHasOwner(final DiagnosticChain diagnosticChain, final Map<Object, Object> context)
247     {
248         return this.slot.validateHasOwner(diagnosticChain, context);
249     }
250 
251     /**
252      * @see org.eclipse.uml2.uml.Element#validateNotOwnSelf(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
253      */
254     public boolean validateNotOwnSelf(final DiagnosticChain diagnosticChain, final Map<Object, Object> context)
255     {
256         return this.slot.validateNotOwnSelf(diagnosticChain, context);
257     }
258 
259     /**
260      * @see org.eclipse.uml2.uml.Element#allOwnedElements()
261      */
262     public EList<Element> allOwnedElements()
263     {
264         return this.slot.allOwnedElements();
265     }
266 
267     /**
268      * @see org.eclipse.uml2.uml.Element#mustBeOwned()
269      */
270     public boolean mustBeOwned()
271     {
272         return this.slot.mustBeOwned();
273     }
274 
275     /**
276      * @see org.eclipse.uml2.uml.Element#createEAnnotation(String)
277      */
278     public EAnnotation createEAnnotation(final String string)
279     {
280         return this.slot.createEAnnotation(string);
281     }
282 
283     /**
284      * @param stereotype
285      */
286     public void apply(final Stereotype stereotype)
287     {
288         this.slot.applyStereotype(stereotype);
289     }
290 
291     /**
292      * @see org.eclipse.uml2.uml.Element#applyStereotype(org.eclipse.uml2.uml.Stereotype)
293      */
294     public EObject applyStereotype(final Stereotype stereotype)
295     {
296         return this.slot.applyStereotype(stereotype);
297     }
298 
299     /**
300      * @see org.eclipse.uml2.uml.Element#getApplicableStereotype(String)
301      */
302     public Stereotype getApplicableStereotype(final String string)
303     {
304         return this.slot.getApplicableStereotype(string);
305     }
306 
307     /**
308      * @see org.eclipse.uml2.uml.Element#getApplicableStereotypes()
309      */
310     public EList<Stereotype> getApplicableStereotypes()
311     {
312         return this.slot.getApplicableStereotypes();
313     }
314 
315     /**
316      * @see org.eclipse.uml2.uml.Element#getAppliedStereotype(String)
317      */
318     public Stereotype getAppliedStereotype(final String string)
319     {
320         return this.slot.getAppliedStereotype(string);
321     }
322 
323     /**
324      * @see org.eclipse.uml2.uml.Element#getAppliedSubstereotype(org.eclipse.uml2.uml.Stereotype, String)
325      */
326     public Stereotype getAppliedSubstereotype(final Stereotype stereotype, final String string)
327     {
328         return this.slot.getAppliedSubstereotype(stereotype, string);
329     }
330 
331     /**
332      * @see org.eclipse.uml2.uml.Element#getAppliedStereotypes()
333      */
334     public EList<Stereotype> getAppliedStereotypes()
335     {
336         return this.slot.getAppliedStereotypes();
337     }
338 
339     /**
340      * @see org.eclipse.uml2.uml.Element#getAppliedSubstereotypes(org.eclipse.uml2.uml.Stereotype)
341      */
342     public EList<Stereotype> getAppliedSubstereotypes(final Stereotype stereotype)
343     {
344         return this.slot.getAppliedSubstereotypes(stereotype);
345     }
346 
347     /**
348      * @see org.eclipse.uml2.uml.Element#getModel()
349      */
350     public Model getModel()
351     {
352         return (Model) UmlUtilities.findModel(this.slot);
353     }
354 
355     /**
356      * @see org.eclipse.uml2.uml.Element#getNearestPackage()
357      */
358     public Package getNearestPackage()
359     {
360         return this.slot.getNearestPackage();
361     }
362 
363     /**
364      * @see org.eclipse.uml2.uml.Element#getValue(org.eclipse.uml2.uml.Stereotype, String)
365      */
366     public Object getValue(final Stereotype stereotype, final String string)
367     {
368         return this.slot.getValue(stereotype, string);
369     }
370 
371     /**
372      * @see org.eclipse.uml2.uml.Element#isStereotypeApplicable(org.eclipse.uml2.uml.Stereotype)
373      */
374     public boolean isStereotypeApplicable(final Stereotype stereotype)
375     {
376         return this.slot.isStereotypeApplicable(stereotype);
377     }
378 
379     /**
380      * @param stereotype
381      * @return slot.isStereotypeApplied(stereotype)
382      */
383     @Deprecated
384     public boolean isApplied(final Stereotype stereotype)
385     {
386         return this.slot.isStereotypeApplied(stereotype);
387     }
388 
389     /**
390      * @see org.eclipse.uml2.uml.Element#isStereotypeApplied(org.eclipse.uml2.uml.Stereotype)
391      */
392     public boolean isStereotypeApplied(final Stereotype stereotype)
393     {
394         return this.slot.isStereotypeApplied(stereotype);
395     }
396 
397     /**
398      * @param stereotype
399      * @return slot.isStereotypeRequired(stereotype)
400      */
401     @Deprecated
402     public boolean isRequired(final Stereotype stereotype)
403     {
404         return this.slot.isStereotypeRequired(stereotype);
405     }
406 
407     /**
408      * @see org.eclipse.uml2.uml.Element#isStereotypeRequired(org.eclipse.uml2.uml.Stereotype)
409      */
410     public boolean isStereotypeRequired(final Stereotype stereotype)
411     {
412         return this.slot.isStereotypeRequired(stereotype);
413     }
414 
415     /**
416      * @see org.eclipse.uml2.uml.Element#setValue(org.eclipse.uml2.uml.Stereotype, String, Object)
417      */
418     public void setValue(final Stereotype stereotype, final String string, final Object object)
419     {
420         this.slot.setValue(stereotype, string, object);
421     }
422 
423     /**
424      * @see org.eclipse.uml2.uml.Element#hasValue(org.eclipse.uml2.uml.Stereotype, String)
425      */
426     public boolean hasValue(final Stereotype stereotype, final String string)
427     {
428         return this.slot.hasValue(stereotype, string);
429     }
430 
431     /**
432      * @param stereotype
433      */
434     public void unapply(final Stereotype stereotype)
435     {
436         this.slot.unapplyStereotype(stereotype);
437     }
438 
439     /**
440      * @see org.eclipse.uml2.uml.Element#unapplyStereotype(org.eclipse.uml2.uml.Stereotype)
441      */
442     public EObject unapplyStereotype(final Stereotype stereotype)
443     {
444         return this.slot.unapplyStereotype(stereotype);
445     }
446 
447     /**
448      * @see org.eclipse.uml2.uml.Element#destroy()
449      */
450     public void destroy()
451     {
452         this.slot.destroy();
453     }
454 
455     // TODO: Map getAppliedVersion?
456     /*public String getAppliedVersion(Stereotype stereotype)
457     {
458         return this.slot.getAppliedVersion(stereotype);
459     }*/
460 
461     /**
462      * @see org.eclipse.uml2.uml.Element#addKeyword(String)
463      */
464     public boolean addKeyword(final String string)
465     {
466         return this.slot.addKeyword(string);
467     }
468 
469     /**
470      * @see org.eclipse.uml2.uml.Element#getKeywords()
471      */
472     public EList<String> getKeywords()
473     {
474         return this.slot.getKeywords();
475     }
476 
477     /**
478      * @see org.eclipse.uml2.uml.Element#hasKeyword(String)
479      */
480     public boolean hasKeyword(final String string)
481     {
482         return this.slot.hasKeyword(string);
483     }
484 
485     /**
486      * @see org.eclipse.uml2.uml.Element#removeKeyword(String)
487      */
488     public boolean removeKeyword(final String string)
489     {
490         return this.slot.removeKeyword(string);
491     }
492 
493     /**
494      * @see org.eclipse.emf.ecore.EModelElement#getEAnnotations()
495      */
496     public EList<EAnnotation> getEAnnotations()
497     {
498         return this.slot.getEAnnotations();
499     }
500 
501     /**
502      * @see org.eclipse.emf.ecore.EModelElement#getEAnnotation(String)
503      */
504     public EAnnotation getEAnnotation(final String string)
505     {
506         return this.slot.getEAnnotation(string);
507     }
508 
509     /**
510      * @see org.eclipse.emf.common.notify.Notifier#eAdapters()
511      */
512     public EList<Adapter> eAdapters()
513     {
514         return this.slot.eAdapters();
515     }
516 
517     /**
518      * @see org.eclipse.emf.common.notify.Notifier#eDeliver()
519      */
520     public boolean eDeliver()
521     {
522         return this.slot.eDeliver();
523     }
524 
525     /**
526      * @see org.eclipse.emf.common.notify.Notifier#eSetDeliver(boolean)
527      */
528     public void eSetDeliver(final boolean deliver)
529     {
530         this.slot.eSetDeliver(deliver);
531     }
532 
533     /**
534      * @see org.eclipse.emf.ecore.EObject#eIsProxy()
535      */
536     public boolean eIsProxy()
537     {
538         return this.slot.eIsProxy();
539     }
540 
541     /**
542      * @see org.eclipse.emf.ecore.EObject#eClass()
543      */
544     public EClass eClass()
545     {
546         return this.slot.eClass();
547     }
548 
549     /**
550      * @see org.eclipse.emf.ecore.EObject#eContainer()
551      */
552     public EObject eContainer()
553     {
554         return this.slot.eContainer();
555     }
556 
557     /**
558      * @see org.eclipse.emf.ecore.EObject#eContents()
559      */
560     public EList<EObject> eContents()
561     {
562         return this.slot.eContents();
563     }
564 
565     /**
566      * @see org.eclipse.emf.ecore.EObject#eCrossReferences()
567      */
568     public EList<EObject> eCrossReferences()
569     {
570         return this.slot.eCrossReferences();
571     }
572 
573     /**
574      * @see org.eclipse.emf.ecore.EObject#eAllContents()
575      */
576     public TreeIterator<EObject> eAllContents()
577     {
578         return this.slot.eAllContents();
579     }
580 
581     /**
582      * @see org.eclipse.emf.ecore.EObject#eContainmentFeature()
583      */
584     public EReference eContainmentFeature()
585     {
586         return this.slot.eContainmentFeature();
587     }
588 
589     /**
590      * @see org.eclipse.emf.ecore.EObject#eContainingFeature()
591      */
592     public EStructuralFeature eContainingFeature()
593     {
594         return this.slot.eContainingFeature();
595     }
596 
597     /**
598      * @see org.eclipse.emf.ecore.EObject#eResource()
599      */
600     public Resource eResource()
601     {
602         return this.slot.eResource();
603     }
604 
605     /**
606      * @see org.eclipse.emf.ecore.EObject#eGet(org.eclipse.emf.ecore.EStructuralFeature)
607      */
608     public Object eGet(final EStructuralFeature eStructuralFeature)
609     {
610         return this.slot.eGet(eStructuralFeature);
611     }
612 
613     /**
614      * @see org.eclipse.emf.common.notify.Notifier#eNotify(org.eclipse.emf.common.notify.Notification)
615      */
616     public void eNotify(final Notification notification)
617     {
618         this.slot.eNotify(notification);
619     }
620 
621     /**
622      * @see org.eclipse.uml2.uml.Element#getRelationships()
623      */
624     public EList<Relationship> getRelationships()
625     {
626         return this.slot.getRelationships();
627     }
628 
629     /**
630      * @see org.eclipse.uml2.uml.Element#getRelationships(org.eclipse.emf.ecore.EClass)
631      */
632     public EList<Relationship> getRelationships(final EClass eClass)
633     {
634         return this.slot.getRelationships(eClass);
635     }
636 
637     /**
638      * @see org.eclipse.uml2.uml.Element#getRequiredStereotype(String)
639      */
640     public Stereotype getRequiredStereotype(final String qualifiedName)
641     {
642         return this.slot.getRequiredStereotype(qualifiedName);
643     }
644 
645     /**
646      * @see org.eclipse.uml2.uml.Element#getRequiredStereotypes()
647      */
648     public EList<Stereotype> getRequiredStereotypes()
649     {
650         return this.slot.getRequiredStereotypes();
651     }
652 
653     /**
654      * @see org.eclipse.uml2.uml.Element#getSourceDirectedRelationships()
655      */
656     public EList<DirectedRelationship> getSourceDirectedRelationships()
657     {
658         return this.slot.getSourceDirectedRelationships();
659     }
660 
661     /**
662      * @see org.eclipse.uml2.uml.Element#getSourceDirectedRelationships(org.eclipse.emf.ecore.EClass)
663      */
664     public EList<DirectedRelationship> getSourceDirectedRelationships(final EClass eClass)
665     {
666         return this.slot.getSourceDirectedRelationships(eClass);
667     }
668 
669     /**
670      * @see org.eclipse.uml2.uml.Element#getStereotypeApplication(org.eclipse.uml2.uml.Stereotype)
671      */
672     public EObject getStereotypeApplication(final Stereotype stereotype)
673     {
674         return this.slot.getStereotypeApplication(stereotype);
675     }
676 
677     /**
678      * @see org.eclipse.uml2.uml.Element#getStereotypeApplications()
679      */
680     public EList<EObject> getStereotypeApplications()
681     {
682         return this.slot.getStereotypeApplications();
683     }
684 
685     /**
686      * @see org.eclipse.uml2.uml.Element#getTargetDirectedRelationships()
687      */
688     public EList<DirectedRelationship> getTargetDirectedRelationships()
689     {
690         return this.slot.getTargetDirectedRelationships();
691     }
692 
693     /**
694      * @see org.eclipse.uml2.uml.Element#getTargetDirectedRelationships(org.eclipse.emf.ecore.EClass)
695      */
696     public EList<DirectedRelationship> getTargetDirectedRelationships(final EClass eClass)
697     {
698         return this.slot.getTargetDirectedRelationships(eClass);
699     }
700 
701     /**
702      * UML2 3.1 (Eclipse 3.6) only
703      * @see org.eclipse.emf.ecore.EObject#eInvoke(org.eclipse.emf.ecore.EOperation, org.eclipse.emf.common.util.EList)
704      */
705     public Object eInvoke(final EOperation operation, final EList<?> arguments) throws InvocationTargetException
706     {
707         return this.slot.eInvoke(operation, arguments);
708     }
709 }