1 19 package org.sample.registry.model.impl; 20 21 import org.netbeans.modules.xml.xam.AbstractComponent; 22 import org.netbeans.modules.xml.xam.AbstractReference; 23 import org.sample.registry.model.ReferenceableRegistryComponent; 24 import org.sample.registry.model.RegistryComponent; 25 26 public class Reference<T extends ReferenceableRegistryComponent> extends AbstractReference<T> { 27 28 29 public Reference(T referenced, Class <T> referencedType, AbstractComponent container) { 30 super(referenced, referencedType, container); 31 } 32 33 public Reference(String refString, Class <T> referencedType, AbstractComponent container) { 34 super(referencedType, container, refString); 35 } 36 37 protected RegistryComponent getReferencingComponent() { 38 return (RegistryComponent) super.getParent(); 39 } 40 41 public T get() { 42 if (getReferenced() == null) { 43 T ref = new FindByNameAndTypeVisitor<T>().find( 44 getReferencingComponent().getModel().getRootComponent(), refString, getType()); 45 if (ref != null) { 46 setReferenced(ref); 47 } 48 } 49 return getReferenced(); 50 } 51 } 52 | Popular Tags |