Class LazyId
java.lang.Object
io.fluxcapacitor.javaclient.common.LazyId
A lazily initialized identifier that serializes as a plain string.
Unlike using Lombok's lazy getters, LazyId
ensures the ID is generated only once and remains stable even
after calling .toBuilder()
on the enclosing object. This makes it useful in scenarios where the ID should be
deterministically generated only once per logical instance, including deserialization and cloning scenarios.
If the ID is not provided directly, a supplier (e.g., FluxCapacitor::generateId
) can be used to compute it
lazily on first access. The ID is then cached and reused.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
LazyId
public LazyId()Constructs a newLazyId
with a default ID supplier usingFluxCapacitor::generateId
. -
LazyId
Constructs a newLazyId
with the specified supplier. The ID will be computed when accessed.- Parameters:
supplier
- the supplier used to generate the ID
-
LazyId
Constructs aLazyId
with a known ID value. No computation will occur.- Parameters:
id
- the ID value (converted to string if non-null)
-
-
Method Details