Interface ObservableView<T>

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

public interface ObservableView<T> extends Supplier<T>
A read-only observable property.
Since:
4.2.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A listener for changes in observable views and properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a change listener to this property view.
    default Optional<T>
    Returns the nonnull value of this property, or Optional.empty() if null or not initialized.
    get()
    Returns the value of this property.
    default T
    Returns the value of this property, or null if not initialized.
    boolean
    Returns whether this property has been set to a value.
    void
    Removes a change listener from this property view if present.
  • 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>
      Returns:
      the value of this property
      Throws:
      IllegalStateException - if not initialized
      See Also:
    • getOrNull

      @Nullable default 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