Package com.avanza.astrix.config
Interface DynamicProperty<T>
-
- All Known Implementing Classes:
DynamicBooleanProperty,DynamicEnumProperty,DynamicIntProperty,DynamicListProperty,DynamicLongProperty,DynamicOptionalProperty,DynamicSetProperty,DynamicStringProperty
public interface DynamicProperty<T>A property that can change state even after it is read from aDynamicConfigSource.DynamicProperty instances are designed to be lightweight with no dependencies to the underlying configuration sources, thereby keeping consumers of DynamicProperty instances decoupled from the underlying configuration sources.
- Author:
- Elias Lindholm (elilin)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(DynamicPropertyListener<T> listener)Adds a given listener to the underlying property.TgetCurrentValue()Returns the current value of this DynamicProperty.voidremoveListener(DynamicPropertyListener<T> listener)Removes a given listener.voidsetValue(T value)Sets the value of this DynamicProperty.
-
-
-
Method Detail
-
addListener
void addListener(DynamicPropertyListener<T> listener)
Adds a given listener to the underlying property. The listener will be notified each time the property value changes.Events are not guaranteed to be received in the same order as the underlying property is set.
The listener will be notified synchronously on the same thread that mutates the underlying property, so don't do any long-running work on the thread that notifies the
DynamicPropertyListener.
-
removeListener
void removeListener(DynamicPropertyListener<T> listener)
Removes a given listener. After remove the given listener will not receive events when this property is changed.
-
getCurrentValue
T getCurrentValue()
Returns the current value of this DynamicProperty. For primitive types the boxed version is returned (never null).
-
setValue
void setValue(T value)
Sets the value of this DynamicProperty. If the underlying property is a primitive type then this method throwsNullPointerExceptionwhen passing a null argument. All other DynamicProperty types accepts null as a value.
-
-