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 TypeMethodDescription@Nullable EapplyStateChange(UnaryOperator<@Nullable E> change) Change the current state of the entity using the given {code change} function.@Nullable Eentity()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
nullwhen no entity was found for, or could be constructed from. For example while resolving a create-if-missing flow. In that case, theManagedEntitywrapper itself is still returned by theRepository, and may still be live-tracked (e.g. for event-sourced entities), so it reflects a creation event appended later in the sameProcessingContext.- Returns:
- the current state of the entity, or
nullwhen it could not be found or constructed
-
applyStateChange
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.
-