public Object getMapKey(Object target) throws PropertyException { return mapKeyAccessor.getValue(target); } }
/** * 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; } }
@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 writePropertyDirectly(Object object, Object oldValue, Object newValue) throws PropertyException { accessor.setValue(object, newValue); }
public EmbeddedFieldAccessor(EmbeddableDescriptor embeddableDescriptor, Accessor embeddedAccessor, Accessor embeddableAccessor) { this.propertyPath = embeddedAccessor.getName() + "." + embeddableAccessor.getName(); this.embeddableDescriptor = embeddableDescriptor; this.embeddableAccessor = embeddableAccessor; this.embeddedAccessor = embeddedAccessor; }
/** * 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; }
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; }
public BaseProperty(ClassDescriptor owner, Accessor accessor) { if (accessor == null) { throw new IllegalArgumentException("Null accessor"); } this.accessor = accessor; this.owner = owner; this.name = accessor.getName(); }
public Object getMapKey(Object target) throws PropertyException { return mapKeyAccessor.getValue(target); } }
/** * 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; }
/** * 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); }
public Object readPropertyDirectly(Object object) throws PropertyException { return accessor.getValue(object); }
@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); }
public void setValue(Object object, Object newValue) throws PropertyException { embeddableAccessor.setValue(getEmbeddable(object), newValue); }
public boolean isFault(Object object) { if (superclassDescriptor != null) { return superclassDescriptor.isFault(object); } if (object == null) { return false; } return HOLLOW_STATE.equals(persistenceStateAccessor.getValue(object)); }
@Override public boolean isFault(Object source) { Object target = accessor.getValue(source); return target == null || target instanceof Fault || ((ValueHolder) target).isFault(); }
@Override public Object readPropertyDirectly(Object object) throws PropertyException { ValueHolder holder = (ValueHolder) accessor.getValue(object); // TODO: Andrus, 2/9/2006 ValueHolder will resolve an object in a call to // 'getValue'; this is inconsistent with 'readPropertyDirectly' contract return (holder != null) ? holder.getValueDirectly() : null; }
/** * Returns object property using JavaBean-compatible introspection with one * addition - a property can be a dot-separated property name path. */ public static Object getProperty(Object object, String nestedPropertyName) throws CayenneRuntimeException { return accessor(nestedPropertyName).getValue(object); }
public static PropertyReader reader(String fixedPropertyName) { Accessor accessor = PropertyUtils.accessor(fixedPropertyName); return (root, name) -> accessor.getValue(root); }