Class PropertyValue<T>

java.lang.Object
is.codion.common.reactive.value.AbstractValue<T>
is.codion.common.utilities.property.PropertyValue<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
Observable<T>, Observer<T>, Value<T>

public final class PropertyValue<T> extends AbstractValue<T>
A Value associated with a named property.
  • Method Details

    • name

      public String name()
      Returns:
      the name of the property this value represents
    • getOrThrow

      public T getOrThrow()
      Returns:
      the value
    • remove

      public void remove()
      Sets this value to null as well as removing it from the underlying store and clearing the system property.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getValue

      protected @Nullable T getValue()
      Returns the actual internal
      Returns:
      the value
    • setValue

      protected void setValue(@Nullable T value)
      Sets the actual internal
      Parameters:
      value - the value
    • observable

      public Observable<T> observable()
      Specified by:
      observable in interface Value<T>
      Returns:
      a read-only Observable instance for this value
    • observer

      public final Observer<T> observer()
      Specified by:
      observer in interface Observable<T>
      Returns:
      an Observer notified each time the observed value may have changed
    • changed

      public final Observer<ValueChange<T>> changed()
      Specified by:
      changed in interface Value<T>
      Returns:
      an Observer notified when this value has changed
    • locked

      public final Value.Locked locked()
      Description copied from interface: Value

      Locking a value prevents it from being changed, it does not prevent it from being set.

      Note that locking a value does not prevent linked values from being changed.

      A locked value in a linked value chain, may cause it to go out of sync, since any subsequent linked values will not be updated after a locked value is encountered.

      Specified by:
      locked in interface Value<T>
      Returns:
      the Value.Locked instance controlling whether this value is locked
    • isNullable

      public final boolean isNullable()
      Description copied from interface: Observable
      If false then get() is guaranteed to never return null.
      Specified by:
      isNullable in interface Observable<T>
      Returns:
      true if this observable can be null
    • link

      public final void link(Value<T> originalValue)
      Description copied from interface: Value
      Creates a bidirectional link between this and the given original value, so that changes in one are reflected in the other. Note that after a call to this method this value is the same as originalValue.
      Specified by:
      link in interface Value<T>
      Parameters:
      originalValue - the original value to link this value to
    • unlink

      public final void unlink(Value<T> originalValue)
      Description copied from interface: Value
      Unlinks this value from the given original value
      Specified by:
      unlink in interface Value<T>
      Parameters:
      originalValue - the original value to unlink from this one
    • link

      public final void link(Observable<T> observable)
      Description copied from interface: Value
      Creates a unidirectional link between this value and the given observable, so that changes in the observable are reflected in this one. Note that after a call to this method the value of this value is the same as the observable.
      Specified by:
      link in interface Value<T>
      Parameters:
      observable - the observable to link this value to
    • unlink

      public final void unlink(Observable<T> observable)
      Description copied from interface: Value
      Unlinks this value from the given observable
      Specified by:
      unlink in interface Value<T>
      Parameters:
      observable - the observable to unlink
    • addValidator

      public final boolean addValidator(Value.Validator<? super T> validator)
      Description copied from interface: Value
      Adds a validator to this Value. Adding the same validator again has no effect.
      Specified by:
      addValidator in interface Value<T>
      Parameters:
      validator - the validator
      Returns:
      true if this value did not already contain the specified validator
    • removeValidator

      public final boolean removeValidator(Value.Validator<? super T> validator)
      Description copied from interface: Value
      Removes the given validator from this value
      Specified by:
      removeValidator in interface Value<T>
      Parameters:
      validator - the validator
      Returns:
      true if this value contained the specified validator
    • validate

      public final void validate(T value)
      Description copied from interface: Value
      Validate the given value using all validators
      Specified by:
      validate in interface Value<T>
      Parameters:
      value - the value to validate
    • notifyObserver

      protected final void notifyObserver()
      Notifies the underlying observer that the underlying value has changed or at least that it may have changed
    • createObservable

      protected Observable<T> createObservable()
      Returns:
      a new Observable instance representing this value