org.springframework.data.mapping

## Interface PersistentPropertyAccessor<T>

All Known Subinterfaces:
  PersistentPropertyPathAccessor<T>

All Known Implementing Classes:
  ConvertingPropertyAccessor, InstantiationAwarePropertyAccessor

    public interface PersistentPropertyAccessor<T>

Domain service to allow accessing and setting `PersistentProperty`s of an entity. Usually obtained through `PersistentEntity.getPropertyAccessor(Object)`. In case type conversion shall be applied on property access, use a `ConvertingPropertyAccessor`.

This service supports mutation for immutable classes by creating new object instances. These are managed as state of `PersistentPropertyAccessor` and must be obtained from `getBean()` after processing all updates.

Since:
  1.10
Author:
  Oliver Gierke, Mark Paluch
See Also:
  `PersistentEntity.getPropertyAccessor(Object)`, `ConvertingPropertyAccessor`

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
`T` `getBean()` Returns the underlying bean.
`Object` `getProperty(PersistentProperty<?> property)` Returns the value of the given `PersistentProperty` of the underlying bean instance.
`default Object` `getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path)` Deprecated. since 2.3, use `PersistentPropertyPathAccessor.getProperty(PersistentPropertyPath)` instead
`default Object` `getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path, TraversalContext context)` Deprecated. since 2.3, use `PersistentPropertyPathAccessor.getProperty(PersistentPropertyPath, org.springframework.data.mapping.AccessOptions.GetOptions)` instead.
`void` `setProperty(PersistentProperty<?> property, Object value)` Sets the given `PersistentProperty` to the given value.
`default void` `setProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path, Object value)` Deprecated. since 2.3, use `PersistentPropertyPathAccessor.setProperty(PersistentPropertyPath, Object)` instead.

### Method Detail

#### setProperty

    void setProperty(PersistentProperty<?> property,
                     @Nullable
                     Object value)

Sets the given `PersistentProperty` to the given value. Will do type conversion if a `ConversionService` is configured.

Parameters:
  `property` - must not be null.
  `value` - can be null.
Throws:
  `MappingException` - in case an exception occurred when setting the property value.

#### setProperty

    @Deprecated
    default void setProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path,
                                         @Nullable
                                         Object value)

Deprecated. since 2.3, use `PersistentPropertyPathAccessor.setProperty(PersistentPropertyPath, Object)` instead.
Sets the given value for the `PersistentProperty` pointed to by the given `PersistentPropertyPath`. The lookup of intermediate values must not yield null.

Parameters:
  `path` - must not be null or empty.
  `value` - can be null.
Since:
  2.1

#### getProperty

    @Nullable
    Object getProperty(PersistentProperty<?> property)

Returns the value of the given `PersistentProperty` of the underlying bean instance.

Parameters:
  `property` - must not be null.
Returns:
  can be null.

#### getProperty

    @Deprecated
     @Nullable
    default Object getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path)

Deprecated. since 2.3, use `PersistentPropertyPathAccessor.getProperty(PersistentPropertyPath)` instead
Return the value pointed to by the given `PersistentPropertyPath`. If the given path is empty, the wrapped bean is returned.

Parameters:
  `path` - must not be null.
Returns:
Since:
  2.1

#### getProperty

    @Nullable
     @Deprecated
    default Object getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path,
                                                      TraversalContext context)

Deprecated. since 2.3, use `PersistentPropertyPathAccessor.getProperty(PersistentPropertyPath, org.springframework.data.mapping.AccessOptions.GetOptions)` instead.
Return the value pointed to by the given `PersistentPropertyPath`. If the given path is empty, the wrapped bean is returned. On each path segment value lookup, the resulting value is post-processed by handlers registered on the given `TraversalContext` context. This can be used to unwrap container types that are encountered during the traversal.

Parameters:
  `path` - must not be null.
  `context` - must not be null.
Returns:
Since:
  2.2

#### getBean

    T getBean()

Returns the underlying bean. The actual instance may change between `setProperty(PersistentProperty, Object)` calls.

Returns:
  will never be null.