public void writePropertyDirectly(Object object, Object oldValue, Object newValue) throws PropertyException { accessor.setValue(object, newValue); }
public Object createObject(Object owner, String embeddedProperty) { Object embeddable; try { embeddable = embeddableClass.newInstance(); } catch (Throwable e) { throw new PropertyException("Error creating embeddable object of class '" + embeddableClass.getName() + "'", e); } ownerAccessor.setValue(embeddable, owner); embeddedPropertyAccessor.setValue(embeddable, embeddedProperty); return embeddable; }
/** * Sets object property using JavaBean-compatible introspection with one * addition - a property can be a dot-separated property name path. Before * setting a value attempts to convert it to a type compatible with the * object property. Automatic conversion is supported between strings and * basic types like numbers or primitives. */ public static void setProperty(Object object, String nestedPropertyName, Object value) throws CayenneRuntimeException { accessor(nestedPropertyName).setValue(object, value); }
@Override public void setValue(Object object, Object newValue) throws PropertyException { if (object == null) { return; } Accessor segmentAccessor = getOrCreateSegmentAccessor(object.getClass(), segmentName); if (nextAccessor != null) { nextAccessor.setValue(segmentAccessor.getValue(object), newValue); } else { segmentAccessor.setValue(object, newValue); } } }
public void setValue(Object object, Object newValue) throws PropertyException { embeddableAccessor.setValue(getEmbeddable(object), newValue); }
/** * Checks that an object's List field described by this property is set, injecting a * List if needed. */ protected ValueHolder ensureCollectionValueHolderSet(Object object) throws PropertyException { Object value = accessor.getValue(object); if (value == null || value instanceof Fault) { value = createCollectionValueHolder(object); accessor.setValue(object, value); } return (ValueHolder) value; }
/** * Checks that an object's ValueHolder field described by this property is set, * injecting a ValueHolder if needed. */ protected ValueHolder ensureValueHolderSet(Object object) throws PropertyException { ValueHolder holder = (ValueHolder) accessor.getValue(object); if (holder == null) { holder = createValueHolder(object); accessor.setValue(object, holder); } return holder; }
@Override public void writePropertyDirectly(Object object, Object oldValue, Object newValue) throws PropertyException { ValueHolder holder = (ValueHolder) accessor.getValue(object); if (holder == null) { holder = createValueHolder(object); accessor.setValue(object, holder); } holder.setValueDirectly(newValue); }
/** * Returns an embeddable object for the owner object, initializing embeddable if it is * null. Currently supports only one level of embedding. */ protected Object getEmbeddable(Object owner) { Object embeddable = embeddedAccessor.getValue(owner); if (embeddable == null) { embeddable = embeddableDescriptor.createObject(owner, embeddedAccessor .getName()); embeddedAccessor.setValue(owner, embeddable); } return embeddable; } }