1 8 9 15 package jfun.yan; 16 17 import jfun.util.beans.Bean; 18 import jfun.util.beans.BeanType; 19 import jfun.yan.function.Function; 20 21 27 final class PropertyReadingBinder 28 extends BeanPropertyComponentBinder implements ComponentBinder { 29 private final BeanType beanType; 30 private final String prop; 31 32 PropertyReadingBinder(final BeanType beanType, final String prop) { 33 this.beanType = beanType; 34 this.prop = prop; 35 } 36 37 Function toFunction(Object v){ 38 return Functions.getter(Bean.instance(beanType,v), prop); 39 } 40 public boolean equals(Object obj) { 41 if(obj instanceof PropertyReadingBinder){ 42 final PropertyReadingBinder other = (PropertyReadingBinder)obj; 43 return prop.equals(other.prop) && beanType.equals(other.beanType); 44 } 45 else return false; 46 } 47 public int hashCode() { 48 return beanType.hashCode()*31+prop.hashCode(); 49 } 50 } 51 | Popular Tags |