Record Class BootstrapState

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.bootstrap.BootstrapState
Record Components:
tenant - tenant scope; null becomes TenantId.DEFAULT
adminCreated - true once the initial admin has been created for this tenant
adminCreatedAt - completion instant; required when adminCreated is true, must be empty when it is false

@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 Details

    • BootstrapState

      public BootstrapState(TenantId tenant, boolean adminCreated, Optional<Instant> adminCreatedAt)
      Validates record invariants.
      Parameters:
      tenant - tenant scope; null becomes DEFAULT
      adminCreated - completion flag
      adminCreatedAt - completion instant; null becomes empty; presence must match adminCreated
  • Method Details

    • required

      public static BootstrapState required(TenantId tenant)
      Builds the "bootstrap still required" state for tenant.
      Parameters:
      tenant - tenant scope
      Returns:
      required-state
    • completed

      public static BootstrapState completed(TenantId tenant, Instant at)
      Builds the "bootstrap completed" state for tenant.
      Parameters:
      tenant - tenant scope
      at - completion instant; must not be null
      Returns:
      completed-state
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tenant

      public TenantId tenant()
      Returns the value of the tenant record component.
      Returns:
      the value of the tenant record component
    • adminCreated

      public boolean adminCreated()
      Returns the value of the adminCreated record component.
      Returns:
      the value of the adminCreated record component
    • adminCreatedAt

      public Optional<Instant> adminCreatedAt()
      Returns the value of the adminCreatedAt record component.
      Returns:
      the value of the adminCreatedAt record component