1 8 9 15 package jfun.yan; 16 17 import java.beans.IntrospectionException ; 18 19 20 26 final class DynamicPropertyReadingBinder implements ComponentBinder { 27 private final String prop; 28 29 public Class bindType(Class type) { 30 return null; 31 } 32 public Verifiable verify(Class type) { 33 try{ 34 return Components.getter(type, null, prop); 35 } 36 catch(IntrospectionException e){ 37 throw new InvalidPropertyException(type, prop, e.getMessage()); 38 } 39 } 40 public Creator bind(Object v) 41 throws IntrospectionException { 42 return Components.getter(v, prop); 43 } 44 DynamicPropertyReadingBinder(final String prop) { 45 this.prop = prop; 46 } 47 48 public boolean equals(Object obj) { 49 if(obj instanceof DynamicPropertyReadingBinder){ 50 final DynamicPropertyReadingBinder other = 51 (DynamicPropertyReadingBinder)obj; 52 return prop.equals(other.prop); 53 } 54 else return false; 55 } 56 public int hashCode() { 57 return prop.hashCode(); 58 } 59 public String toString() { 60 return prop.toString(); 61 } 62 } 63 | Popular Tags |