Interface ManagedEntity<ID,E>

Type Parameters:
ID - The type of identifier of the entity.
E - The type of the entity.

public interface ManagedEntity<ID,E>
A wrapper around an entity whose lifecycle is being managed by an Repository.
Since:
5.0.0
Author:
Allard Buijze
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable E
    applyStateChange(UnaryOperator<@Nullable E> change)
    Change the current state of the entity using the given {code change} function.
    @Nullable E
    The current state of the entity.
    The identifier of the entity.
  • Method Details

    • identifier

      ID identifier()
      The identifier of the entity.
      Returns:
      The identifier of the entity.
    • entity

      @Nullable E entity()
      The current state of the entity.

      This is null when no entity was found for, or could be constructed from. For example while resolving a create-if-missing flow. In that case, the ManagedEntity wrapper itself is still returned by the Repository, and may still be live-tracked (e.g. for event-sourced entities), so it reflects a creation event appended later in the same ProcessingContext.

      Returns:
      the current state of the entity, or null when it could not be found or constructed
    • applyStateChange

      @Nullable E applyStateChange(UnaryOperator<@Nullable E> change)
      Change the current state of the entity using the given {code change} function.
      Parameters:
      change - The function applying the requested change.
      Returns:
      The state of the entity after the change.