1 19 20 package org.apache.cayenne.reflect; 21 22 29 public abstract class BaseProperty implements Property { 30 31 protected ClassDescriptor owner; 32 protected Accessor accessor; 33 34 final String name; 36 37 public BaseProperty(ClassDescriptor owner, Accessor accessor) { 38 39 if (accessor == null) { 40 throw new IllegalArgumentException ("Null accessor"); 41 } 42 43 this.accessor = accessor; 44 this.owner = owner; 45 this.name = accessor.getName(); 46 } 47 48 public Object readProperty(Object object) throws PropertyException { 49 return readPropertyDirectly(object); 50 } 51 52 public void writeProperty(Object object, Object oldValue, Object newValue) 53 throws PropertyException { 54 writePropertyDirectly(object, oldValue, newValue); 55 } 56 57 public String getName() { 58 return name; 59 } 60 61 public abstract boolean visit(PropertyVisitor visitor); 62 63 66 public void injectValueHolder(Object object) throws PropertyException { 67 } 69 70 public Object readPropertyDirectly(Object object) throws PropertyException { 71 return accessor.getValue(object); 72 } 73 74 public void writePropertyDirectly(Object object, Object oldValue, Object newValue) 75 throws PropertyException { 76 accessor.setValue(object, newValue); 77 } 78 79 public String toString() { 80 StringBuffer buffer = new StringBuffer (); 81 buffer.append(getClass().getName()).append('@').append( 82 System.identityHashCode(this)).append('[').append(name).append(']'); 83 return buffer.toString(); 84 } 85 } 86 | Popular Tags |