1 package jfun.yan.xml.nuts.optional; 2 3 import jfun.yan.Component; 4 import jfun.yan.Components; 5 import jfun.yan.xml.nut.ComponentNut; 6 7 15 public class RefNut extends ComponentNut { 16 private Object to; 17 private Class type; 18 19 public Class getType() { 20 return type; 21 } 22 23 public void setType(Class type) { 24 this.type = type; 25 } 26 27 public Object getTo() { 28 return to; 29 } 30 31 public void setTo(Object ref) { 32 this.to = ref; 33 } 34 35 public Component eval(){ 36 if(to!=null) 37 return Components.useKey(to); 38 else{ 39 if(type==null){ 40 raise("either 'to' or 'type' has to be specified"); 41 } 42 return Components.useType(type); 43 } 44 } 45 46 } 47 | Popular Tags |