Class AbstractPropertyListener<T>

java.lang.Object
johnsmith.configoverhauled.api.listener.AbstractPropertyListener<T>
Type Parameters:
T - The underlying data type monitored by this listener.
All Implemented Interfaces:
Property.Listener
Direct Known Subclasses:
BlockPropertyListener, BlocksPropertyListener, BooleanPropertyListener, BoundedPropertyListener, ItemPropertyListener, ItemsPropertyListener, StringPropertyListener

public abstract class AbstractPropertyListener<T> extends Object implements Property.Listener
Abstract base implementation for dynamic configuration property listeners. Facilitates lazy resolution and state synchronization of dynamically generated properties.
  • Field Details

    • cachedProperty

      @Nullable protected @Nullable Property<?> cachedProperty
      The actively tracked property instance. Null prior to initialization or post-invalidation.
    • initialized

      protected volatile boolean initialized
      Tracks the resolution state of the listener instance.
    • typeDefinition

      protected final DynamicPropertyTypeRegistry.TypeDefinition<T> typeDefinition
      The structural definition dictating the property's data type and serialization logic.
    • description

      protected final ConfigDescription description
      The metadata encapsulating the property's identity and organizational hierarchy.
    • defaultValue

      protected final T defaultValue
      The fallback value utilized during property generation.
  • Constructor Details

    • AbstractPropertyListener

      protected AbstractPropertyListener(ConfigDescription description, DynamicPropertyTypeRegistry.TypeDefinition<T> typeDefinition, T defaultValue)
      Constructs a state listener for a dynamic configuration property.
      Parameters:
      description - The structural and organizational metadata for the target property.
      typeDefinition - The registry definition mapping the required data type.
      defaultValue - The default value assigned upon initial property generation.
  • Method Details

    • onPropertyInvalidated

      public void onPropertyInvalidated()
      Executes upon the destruction or desynchronization of the bound property instance. Purges the internal cache and resets the initialization state.
      Specified by:
      onPropertyInvalidated in interface Property.Listener
    • onPropertyChanged

      public void onPropertyChanged()
      Executes upon a state mutation within the bound property. Forces a re-evaluation of the property resolution pipeline.
      Specified by:
      onPropertyChanged in interface Property.Listener
    • resolveProperty

      protected void resolveProperty(boolean forceResolution)
      Resolves the target property from the active configuration manager instance. Lazily binds this listener to the target property to monitor future state mutations.
      Parameters:
      forceResolution - Bypasses the initialization state check to force synchronization.