|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.lang3.concurrent.ConstantInitializer<T>
T
- the type of the object managed by this initializerpublic class ConstantInitializer<T>
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
.
Constructor Summary | |
---|---|
ConstantInitializer(T obj)
Creates a new instance of ConstantInitializer and initializes it
with the object to be managed. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Compares this object with another one. |
T |
get()
Returns the object managed by this initializer. |
T |
getObject()
Directly returns the object that was passed to the constructor. |
int |
hashCode()
Returns a hash code for this object. |
String |
toString()
Returns a string representation for this object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConstantInitializer(T obj)
ConstantInitializer
and initializes it
with the object to be managed. The get()
method will always
return the object passed here. This class does not place any restrictions
on the object. It may be null, then get()
will return
null, too.
obj
- the object to be managed by this initializerMethod Detail |
---|
public final T getObject()
get()
. However, this method does
not declare that it throws an exception.
public T get() throws ConcurrentException
get
in interface ConcurrentInitializer<T>
ConcurrentException
- if an error occurspublic int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
ConstantInitializer
which refers to an object equals to the
object managed by this instance.
equals
in class Object
obj
- the object to compare to
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |