public Object getMapKey(Object target) throws PropertyException { return mapKeyAccessor.getValue(target); } }
public Object getMapKey(Object target) throws PropertyException { return mapKeyAccessor.getValue(target); } }
public Object readPropertyDirectly(Object object) throws PropertyException { return accessor.getValue(object); }
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); }
/** * Returns true if a property ValueHolder is not initialized or is itself a fault. */ @Override public boolean isFault(Object object) { ValueHolder holder = (ValueHolder) accessor.getValue(object); return holder == null || holder.isFault(); }
public Object getValue(Object object) throws PropertyException { return embeddableAccessor.getValue(getEmbeddable(object)); }
/** * Converts a collection into a map indexed by map key. */ protected Map indexCollection(Collection<Object> collection) { // map objects by property Map<Object, Object> map = new HashMap<>((int) (collection.size() * 1.33d) + 1); if (collection.size() > 0) { for (Object next : collection) { Object key = mapKeyAccessor.getValue(next); Object previous = map.put(key, next); if (previous != null && previous != next) { throw new CayenneRuntimeException("Duplicate key '%s' in relationship map. " + "Relationship: %s, source object: %s" , key, relationshipName, relationshipOwner.getObjectId()); } } } return map; }
/** * 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 void invalidate(Object object) { ValueHolder holder = (ValueHolder) accessor.getValue(object); if (holder != null && !holder.isFault()) { holder.invalidate(); } }
/** * 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 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); } } }
@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; } }