Interface ObservableView<T extends @Nullable Object>

Type Parameters:
T - the contained value type
All Superinterfaces:
Supplier<T>
All Known Implementing Classes:
ObservableProperty

public interface ObservableView<T extends @Nullable Object> extends Supplier<T>
A read-only observable property.
Since:
4.2.0
  • Method Details

    • hasValue

      boolean hasValue()
      Returns whether this property has been set to a value.
      Returns:
      whether this property has been set to a value
    • get

      T get()
      Returns the value of this property.
      Specified by:
      get in interface Supplier<T extends @Nullable Object>
      Returns:
      the value of this property
      Throws:
      IllegalStateException - if not initialized
      See Also:
    • getOrNull

      default @Nullable T getOrNull()
      Returns the value of this property, or null if not initialized.
      Returns:
      the value of this property, or null if not initialized
    • find

      default Optional<T> find()
      Returns the nonnull value of this property, or Optional.empty() if null or not initialized.
      Returns:
      the nonnull value of this property, or Optional.empty() if null or not initialized
    • addListener

      void addListener(ObservableView.ChangeListener<? super T> listener)
      Adds a change listener to this property view.
      Parameters:
      listener - the added listener
    • removeListener

      void removeListener(ObservableView.ChangeListener<? super T> listener)
      Removes a change listener from this property view if present.
      Parameters:
      listener - the removed listener