org.jboss.msc.value
Class InjectedValue<T>

java.lang.Object
  extended by org.jboss.msc.inject.RetainingInjector<T>
      extended by org.jboss.msc.value.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.

Author:
David M. Lloyd

Constructor Summary
InjectedValue()
          Construct a new instance.
 
Method Summary
 T getOptionalValue()
          Get the value if it was injected, or return null if it was not.
 T getValue()
          Get the actual value.
 void setValue(Value<T> value)
          Set the value to be injected to a Value instance.
 
Methods inherited from class org.jboss.msc.inject.RetainingInjector
getStoredValue, inject, setStoredValue, uninject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.msc.inject.Injector
inject, uninject
 

Constructor Detail

InjectedValue

public InjectedValue()
Construct a new instance.

Method Detail

getValue

public T getValue()
           throws IllegalStateException
Get the actual value.

Specified by:
getValue in interface Value<T>
Returns:
the actual value
Throws:
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


Copyright © 2011. All Rights Reserved.