Class ConstantInitializer<T>
java.lang.Object
org.apache.commons.lang3.concurrent.ConstantInitializer<T>
- Type Parameters:
- T- the type of the object managed by this initializer
- All Implemented Interfaces:
- ConcurrentInitializer<T>,- FailableSupplier<T,- ConcurrentException> 
A very simple implementation of the 
ConcurrentInitializer interface
 which always returns the same object.
 
 An instance of this class is passed a reference to an object when it is
 constructed. The get() method just returns this object. No
 synchronization is required.
 
 This class is useful for instance for unit testing or in cases where a
 specific object has to be passed to an object which expects a
 ConcurrentInitializer.
 
- Since:
- 3.0
- 
Field SummaryFields inherited from interface org.apache.commons.lang3.function.FailableSupplierNUL
- 
Constructor SummaryConstructorsConstructorDescriptionConstantInitializer(T obj) Creates a new instance ofConstantInitializerand initializes it with the object to be managed.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanCompares this object with another one.get()Returns the object managed by this initializer.final TDirectly returns the object that was passed to the constructor.inthashCode()Returns a hash code for this object.booleanAs aConstantInitializeris initialized on construction this will always return true.toString()Returns a string representation for this object.
- 
Constructor Details- 
ConstantInitializerCreates a new instance ofConstantInitializerand initializes it with the object to be managed. Theget()method will always return the object passed here. This class does not place any restrictions on the object. It may be null, thenget()will return null, too.- Parameters:
- obj- the object to be managed by this initializer
 
 
- 
- 
Method Details- 
equalsCompares this object with another one. This implementation returns true if and only if the passed in object is an instance ofConstantInitializerwhich refers to an object equals to the object managed by this instance.
- 
getReturns the object managed by this initializer. This implementation just returns the object passed to the constructor.- Specified by:
- getin interface- FailableSupplier<T,- ConcurrentException> 
- Returns:
- the object managed by this initializer
- Throws:
- ConcurrentException- if an error occurs
 
- 
getObjectDirectly returns the object that was passed to the constructor. This is the same object as returned byget(). However, this method does not declare that it throws an exception.- Returns:
- the object managed by this initializer
 
- 
hashCodeReturns a hash code for this object. This implementation returns the hash code of the managed object.
- 
isInitializedAs aConstantInitializeris initialized on construction this will always return true.- Returns:
- true.
- Since:
- 3.14.0
 
- 
toStringReturns a string representation for this object. This string also contains a string representation of the object managed by this initializer.
 
-