Class Sealable

java.lang.Object
name.martingeisse.grumpyjson.registry.Sealable
Direct Known Subclasses:
Registry

public abstract class Sealable extends Object
Base class for everything whose lifecycle is divided into configuration phase and run-time phase. Subclasses define what operations are allowed in either phase. The transition from configuration phase to run-time phase is called "sealing" this object. The separation into two phases may allow internal optimization depending on the subclass, and in general enforces to some degree that application code uses this class as intended.
  • Constructor Details

    • Sealable

      public Sealable()
      Constructor
  • Method Details

    • ensureConfigurationPhase

      protected final void ensureConfigurationPhase()
      Throws an IllegalStateException if this object has been sealed already.
    • ensureRunTimePhase

      protected final void ensureRunTimePhase()
      Throws an IllegalStateException if this object has not yet been sealed.
    • seal

      public final void seal()
      Seals this object, moving from the configuration phase to the run-time phase.
    • onSeal

      protected void onSeal()
      Subclasses may perform seal-time operations here, e.g. optimize their internal data structures to prepare for run-time.