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