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