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.
| Modifier and Type | Field and Description |
|---|---|
| private static final String | FMT_TO_STRING
Constant for the format of the string representation. |
| private final T | object
Stores the managed object. |
| Access | Constructor and Description |
|---|---|
| public | ConstantInitializer(final T
the object to be managed by this initializer obj)Creates a new instance of |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: a flag whether the objects are equalthe object to compare to obj)Overrides java. Compares this object with another one. |
| public T | Returns: the object managed by this initializerImplements org. Gets the object managed by this initializer. |
| public final T | Returns: the object managed by this initializerDirectly returns the object that was passed to the constructor. |
| public int | Returns: a hash code for this objectOverrides java. Returns a hash code for this object. |
| public boolean | Returns: true.As a |
| public String | Returns: a string for this objectOverrides java. Returns a string representation for this object. |
| FMT_TO_STRING | back to summary |
|---|---|
| private static final String FMT_TO_STRING Constant for the format of the string representation. | |
| object | back to summary |
|---|---|
| private final T object Stores the managed object. | |
| ConstantInitializer | back to summary |
|---|---|
| public ConstantInitializer(final T obj) Creates a new instance of
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Compares this object with another one. This implementation returns
true if and only if the passed in object is an instance of
| |
| get | back to summary |
|---|---|
| public T get() throws ConcurrentException Implements org. Gets the object managed by this initializer. This implementation just returns the object passed to the constructor.
| |
| getObject | back to summary |
|---|---|
| public final T getObject() Directly returns the object that was passed to the constructor. This is
the same object as returned by
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code for this object. This implementation returns the hash code of the managed object.
| |
| isInitialized | back to summary |
|---|---|
| public boolean isInitialized() As a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation for this object. This string also contains a string representation of the object managed by this initializer. | |