Class AbstractValue<T>

    • Constructor Detail

      • AbstractValue

        protected AbstractValue()
      • AbstractValue

        protected AbstractValue​(T nullValue)
        Creates an AbstractValue instance, which does not notify on set.
        Parameters:
        nullValue - the value to use instead of null
      • AbstractValue

        protected AbstractValue​(T nullValue,
                                boolean notifyOnSet)
        Creates an AbstractValue instance.
        Parameters:
        nullValue - the value to use instead of null
        notifyOnSet - specifies whether to automatically call notifyValueChange() when the value is changed via set(Object)
    • Method Detail

      • set

        public final void set​(T value)
        Description copied from interface: Value
        Sets the value
        Specified by:
        set in interface Value<T>
        Parameters:
        value - the value
      • isNullable

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

        public final void onEvent​(T data)
        Description copied from interface: EventDataListener
        Called when the event occurs.
        Specified by:
        onEvent in interface EventDataListener<T>
        Parameters:
        data - information relating to the event.
      • 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​(ValueObserver<T> originalValueObserver)
        Description copied from interface: Value
        Creates a unidirectional link between this value and the given original value observer, so that changes in the original value are reflected in this one. Note that after a call to this method the value of this value is the same as the original value.
        Specified by:
        link in interface Value<T>
        Parameters:
        originalValueObserver - the original value to link this value to
      • unlink

        public final void unlink​(ValueObserver<T> originalValueObserver)
        Description copied from interface: Value
        Unlinks this value from the given original value observer
        Specified by:
        unlink in interface Value<T>
        Parameters:
        originalValueObserver - the original value observer to unlink
      • linkedValues

        public final Set<Value<T>> linkedValues()
        Specified by:
        linkedValues in interface Value<T>
        Returns:
        an unmodifiable set containing the values that have been linked to this value
      • addValidator

        public final void addValidator​(Value.Validator<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
      • removeValidator

        public final void removeValidator​(Value.Validator<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
      • setValue

        protected abstract void setValue​(T value)
        Sets the actual internal value.
        Parameters:
        value - the value
      • changeObserver

        protected EventObserver<T> changeObserver()
        Returns:
        the change observer to use when adding listeners to this value
      • notifyValueChange

        protected final void notifyValueChange()
        Triggers the change event for this value, using the current value, indicating that the underlying value has changed or at least that it may have changed