1 package jfun.yan; 2 import jfun.util.Misc; 3 import jfun.util.SerializableField; 4 import jfun.yan.function.Function; 5 6 12 final class FieldFunction implements Function{ 13 private final Object obj; 14 private final jfun.util.SerializableField fld; 15 private static final Class [] param_types = new Class [0]; 16 public Object call(Object [] args) 17 throws IllegalAccessException { 18 return fld.getField().get(obj); 19 } 20 public Class [] getParameterTypes() { 21 return param_types; 22 } 23 public Class getReturnType() { 24 return fld.getField().getType(); 25 } 26 public boolean isConcrete(){ 27 return false; 28 } 29 FieldFunction(final Object obj, final java.lang.reflect.Field fld) { 30 this.obj = obj; 31 this.fld = new SerializableField(fld); 32 } 33 34 public boolean equals(Object other) { 35 if(other instanceof FieldFunction){ 36 final FieldFunction m2 = (FieldFunction)other; 37 return obj==m2.obj && fld.equals(m2.fld); 38 } 39 else return false; 40 } 41 public String getName() { 42 return fld.getField().getName(); 43 } 44 public int hashCode() { 45 return Misc.hashcode(obj)*31+fld.hashCode(); 46 } 47 public String toString() { 48 return fld.toString(); 49 } 50 } 51 | Popular Tags |