Interface PatchPresence<T>
- All Known Implementing Classes:
PatchPresence.Omitted,PatchPresence.Present
A patchable attribute or relationship declared as PatchPresence<T> on an annotated
PATCH DTO distinguishes three states: the member was omitted from the update document (PatchPresence.Omitted), the member was supplied with a non-null value (value), or the
member was supplied with an explicit JSON null / null relationship linkage (PatchPresence.Present with a null value). Present with a null value is present — it is
not omission.
The type is deliberately backend-independent and models only presence. It does not own
mapping, validation, persistence, or business semantics; applications inspect the tri-state and
decide how to apply each member. Because nullable Optional is a distinct
concern, PatchPresence<Optional<T>> remains meaningful: an omitted member is PatchPresence.Omitted, while a supplied null becomes Present(Optional.empty()) when that is
the inner type's normal conversion result.
Consume the tri-state with exhaustive pattern matching over PatchPresence.Omitted and PatchPresence.Present, or use the isOmitted() convenience.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe member was omitted from the update document; no requested change.static final recordThe member was supplied. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanReturnstruewhen this state isPatchPresence.Omitted.static <T> PatchPresence<T> omitted()Returns anPatchPresence.Omittedinstance forT.static <T> PatchPresence<T> present(@Nullable T value)
-
Method Details
-
isOmitted
default boolean isOmitted()Returnstruewhen this state isPatchPresence.Omitted. -
omitted
Returns anPatchPresence.Omittedinstance forT. -
present
-