Record Class BootstrapState
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.bootstrap.BootstrapState
- Record Components:
tenant- tenant scope;nullbecomesTenantId.DEFAULTadminCreated-trueonce the initial admin has been created for this tenantadminCreatedAt- completion instant; required whenadminCreatedistrue, must be empty when it isfalse
@ExperimentalJSentinelApi
public record BootstrapState(TenantId tenant, boolean adminCreated, Optional<Instant> adminCreatedAt)
extends Record
Persistent first-run-bootstrap state for one tenant.
Today's InitialAdminBootstrapService keeps the bootstrap
flag inside an AdministratorAccountStore ("does any
administrator exist?") and uses the existence of an administrator
as the bootstrap-completed signal. That works for a single-tenant
single-process deployment but does not carry the "when" or any
tenant scoping, which a multi-tenant deployment needs.
BootstrapStateStore owns one BootstrapState per
tenant; transitioning from adminCreated() false to
true happens exactly once per tenant (the moment the
initial admin is created). The transition is recorded by saving a
new BootstrapState with the completion instant.
-
Constructor Summary
ConstructorsConstructorDescriptionBootstrapState(TenantId tenant, boolean adminCreated, Optional<Instant> adminCreatedAt) Validates record invariants. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theadminCreatedrecord component.Returns the value of theadminCreatedAtrecord component.static BootstrapStateBuilds the "bootstrap completed" state fortenant.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static BootstrapStateBuilds the "bootstrap still required" state fortenant.tenant()Returns the value of thetenantrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BootstrapState
Validates record invariants.- Parameters:
tenant- tenant scope;nullbecomes DEFAULTadminCreated- completion flagadminCreatedAt- completion instant; null becomes empty; presence must matchadminCreated
-
-
Method Details
-
required
Builds the "bootstrap still required" state fortenant.- Parameters:
tenant- tenant scope- Returns:
- required-state
-
completed
Builds the "bootstrap completed" state fortenant.- Parameters:
tenant- tenant scopeat- completion instant; must not benull- Returns:
- completed-state
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
tenant
-
adminCreated
public boolean adminCreated()Returns the value of theadminCreatedrecord component.- Returns:
- the value of the
adminCreatedrecord component
-
adminCreatedAt
Returns the value of theadminCreatedAtrecord component.- Returns:
- the value of the
adminCreatedAtrecord component
-