1 package org.andromda.core.simpleuml; 2 3 import org.andromda.core.uml14.UMLStaticHelper; 4 import org.omg.uml.foundation.core.Attribute; 5 import org.omg.uml.foundation.core.Classifier; 6 import org.omg.uml.foundation.core.Dependency; 7 import org.omg.uml.foundation.core.ModelElement; 8 import org.omg.uml.foundation.core.Operation; 9 10 /*** 11 * dynamic proxy for a Dependency: dynamically supports the UMLDependency, 12 * and org.omg.uml.foundation.core.Dependency interfaces. 13 * 14 * @author <A HREF="http://www.amowers.com">Anthony Mowers</A> 15 */ 16 public class PDependency 17 extends PModelElement 18 implements UMLDependency 19 { 20 21 public static Dependency newInstance( 22 UMLStaticHelper scriptHelper, 23 Dependency dependency) 24 { 25 Class[] interfaces = { 26 UMLDependency.class, 27 Dependency.class 28 }; 29 30 return (Dependency)java.lang.reflect.Proxy.newProxyInstance( 31 dependency.getClass().getClassLoader(), 32 interfaces, 33 new PDependency(dependency, scriptHelper)); 34 } 35 36 37 38 protected PDependency( 39 Dependency dependency, 40 UMLStaticHelper scriptHelper) 41 { 42 super(dependency,scriptHelper); 43 } 44 45 public Object getId() 46 { 47 return modelElement; 48 } 49 50 public ModelElement getTargetType() 51 { 52 Dependency dependency = (Dependency)modelElement; 53 ModelElement supplier = (ModelElement)dependency.getSupplier().iterator().next(); 54 55 if (supplier instanceof Attribute) 56 { 57 return PAttribute.newInstance( 58 scriptHelper, (Attribute)supplier ); 59 } 60 61 if (supplier instanceof Operation) 62 { 63 return POperation.newInstance( 64 scriptHelper, (Operation)supplier ); 65 } 66 67 if (supplier instanceof Classifier) 68 { 69 return PClassifier.newInstance( 70 scriptHelper, (Classifier)supplier ); 71 } 72 73 return PModelElement.newInstance( 74 scriptHelper,supplier ); 75 76 } 77 }