1 19 20 package org.apache.cayenne.reflect; 21 22 import org.apache.cayenne.Fault; 23 import org.apache.cayenne.Persistent; 24 import org.apache.cayenne.ValueHolder; 25 import org.apache.cayenne.util.PersistentObjectList; 26 27 33 public class ListProperty extends BaseToManyProperty { 34 35 public ListProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor, 36 Accessor accessor, String reverseName) { 37 super(owner, targetDescriptor, accessor, reverseName); 38 } 39 40 43 protected ValueHolder createCollectionValueHolder(Object object) 44 throws PropertyException { 45 if (!(object instanceof Persistent)) { 46 47 throw new PropertyException( 48 "ValueHolders for non-persistent objects are not supported.", 49 this, 50 object); 51 } 52 53 return new PersistentObjectList((Persistent) object, getName()); 54 } 55 56 public boolean isFault(Object object) { 57 Object target = accessor.getValue(object); 58 return target == null 59 || target instanceof Fault 60 || ((ValueHolder) target).isFault(); 61 } 62 63 public void invalidate(Object object) { 64 ValueHolder list = (ValueHolder) readPropertyDirectly(object); 65 if(list != null) { 66 list.invalidate(); 67 } 68 } 69 } 70 | Popular Tags |