Package com.dua3.utility.concurrent
Interface ReadOnlyValue<T extends @Nullable Object>
- Type Parameters:
T
- the type of the value
- All Known Subinterfaces:
Value<T>
- All Known Implementing Classes:
SimpleValue
public interface ReadOnlyValue<T extends @Nullable Object>
Represents a read-only value that can be accessed and observed.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(BiConsumer<? super T, ? super T> listener) Adds a change listener for the given method.get()
Retrieves the value of type T.Collection
<BiConsumer<? super T, ? super T>> Returns a collection of all the change listeners currently registered for this method.void
removeChangeListener
(BiConsumer<? super T, ? super T> listener) Removes a change listener for the given method.
-
Method Details
-
get
T get()Retrieves the value of type T.- Returns:
- The value of type T.
-
addChangeListener
Adds a change listener for the given method. The change listener will be triggered whenever the value of type T changes.- Parameters:
listener
- The change listener to be added. The change listener is a BiConsumer that accepts two parameters: - The previous value of type T - The new value of type T The change listener does not return a value.
-
removeChangeListener
Removes a change listener for the given method. The change listener will no longer be triggered whenever the value of type T changes.- Parameters:
listener
- The change listener to be removed. The change listener is a BiConsumer that was previously added using the addChangeListener method.
-
getChangeListeners
Collection<BiConsumer<? super T,? super T>> getChangeListeners()Returns a collection of all the change listeners currently registered for this method.- Returns:
- A collection of change listeners, each represented as a BiConsumer. The change listeners are used to listen for changes in the value of type T.
-