Class InjectedValue<T>

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

    public final class InjectedValue<T>
    extends RetainingInjector<T>
    implements Injector<T>, Value<T>
    A value which is injected from another source. The value may only be read if the injector has populated it.
    • Constructor Detail

      • InjectedValue

        public InjectedValue()
        Construct a new instance.
    • 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.
      • setValue

        public void setValue​(Value<T> value)
        Set the value to be injected to a Value instance.
        Parameters:
        value - the value to set, cannot be null (though it may be Values.nullValue())
      • getOptionalValue

        public T getOptionalValue()
        Get the value if it was injected, or return null if it was not.
        Returns:
        the value or null if it was not injected