org.springframework.data.relational.core.conversion

## Class RelationalEntityVersionUtils

- java.lang.Object
- - org.springframework.data.relational.core.conversion.RelationalEntityVersionUtils

    public class RelationalEntityVersionUtils
    extends Object

Utilities commonly used to set/get properties for instances of RelationalPersistentEntities.

Since:
  2.0
Author:
  Tyler Van Gorder

### Method Summary

All Methods Static Methods Concrete Methods
`static <S> Number` `getVersionNumberFromEntity(S instance, RelationalPersistentEntity<S> persistentEntity, RelationalConverter converter)` Get the current value of the version property for an instance of a relational persistent entity.
`static <S> S` `setVersionNumberOnEntity(S instance, Number version, RelationalPersistentEntity<S> persistentEntity, RelationalConverter converter)` Set the version property on an instance of a relational persistent entity.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getVersionNumberFromEntity

    @Nullable
    public static <S> Number getVersionNumberFromEntity(S instance,
                                                                  RelationalPersistentEntity<S> persistentEntity,
                                                                  RelationalConverter converter)

Get the current value of the version property for an instance of a relational persistent entity.

Parameters:
  `instance` - must not be null.
  `persistentEntity` - must not be null.
  `converter` - must not be null.
Returns:
  Current value of the version property
Throws:
  `IllegalArgumentException` - if the entity does not have a version property.

#### setVersionNumberOnEntity

    public static <S> S setVersionNumberOnEntity(S instance,
                                                 @Nullable
                                                 Number version,
                                                 RelationalPersistentEntity<S> persistentEntity,
                                                 RelationalConverter converter)

Set the version property on an instance of a relational persistent entity. This method returns an instance of the same type with the updated version property and will correctly handle the case where the version is immutable.

Parameters:
  `instance` - must not be null.
  `version` - The value to be set on the version property.
  `persistentEntity` - must not be null.
  `converter` - must not be null.
Returns:
  An instance of the entity with an updated version property.
Throws:
  `IllegalArgumentException` - if the entity does not have a version property.