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
Abstract base implementation for dynamic configuration property listeners.
Facilitates lazy resolution and state synchronization of dynamically generated properties.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable Property<?> The actively tracked property instance.protected final TThe fallback value utilized during property generation.protected final ConfigDescriptionThe metadata encapsulating the property's identity and organizational hierarchy.protected booleanTracks the resolution state of the listener instance.protected final DynamicPropertyTypeRegistry.TypeDefinition<T> The structural definition dictating the property's data type and serialization logic. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPropertyListener(ConfigDescription description, DynamicPropertyTypeRegistry.TypeDefinition<T> typeDefinition, T defaultValue) Constructs a state listener for a dynamic configuration property. -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes upon a state mutation within the bound property.voidExecutes upon the destruction or desynchronization of the bound property instance.protected voidresolveProperty(boolean forceResolution) Resolves the target property from the active configuration manager instance.
-
Field Details
-
cachedProperty
The actively tracked property instance. Null prior to initialization or post-invalidation. -
initialized
protected volatile boolean initializedTracks the resolution state of the listener instance. -
typeDefinition
The structural definition dictating the property's data type and serialization logic. -
description
The metadata encapsulating the property's identity and organizational hierarchy. -
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:
onPropertyInvalidatedin interfaceProperty.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:
onPropertyChangedin interfaceProperty.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.
-