Class DefaultValue<T>

  • Type Parameters:
    T - the value type
    All Implemented Interfaces:
    Value<T>

    public final class DefaultValue<T>
    extends java.lang.Object
    implements Value<T>
    A defaulted value. If the delegate value returns null, a default value will be returned in its place.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultValue​(Value<T> value, Value<? extends T> defaultValue)
      Construct a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T getValue()
      Get the actual value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • value

        private final Value<T> value
      • defaultValue

        private final Value<? extends T> defaultValue
    • Constructor Detail

      • DefaultValue

        public DefaultValue​(Value<T> value,
                            Value<? extends T> defaultValue)
        Construct a new instance.
        Parameters:
        value - the delegate value
        defaultValue - the value to use if the delegate value returns null
    • Method Detail

      • getValue

        public T getValue()
                   throws java.lang.IllegalStateException
        Get the actual value.
        Specified by:
        getValue in interface Value<T>
        Returns:
        the actual value
        Throws:
        java.lang.IllegalStateException - if the value is time-sensitive and the current state does not allow retrieval.