public class ConstantFactory<T> extends Objectimplements Factory <T>, Serializable
No check is made that the object is immutable. In general, only immutable objects should use the constant factory. Mutable objects should use the prototype factory.
| Modifier and Type | Field and Description |
|---|---|
static Factory |
NULL_INSTANCE
Returns null each time
|
| Constructor and Description |
|---|
ConstantFactory(T constantToReturn)
Constructor that performs no validation.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Factory |
constantFactory(T constantToReturn)
Factory method that performs validation.
|
T |
create()
Always return constant.
|
T |
getConstant()
Gets the constant.
|
public static final FactoryNULL_INSTANCE
public ConstantFactory(T constantToReturn)
constantFactory if you want that.
constantToReturn - the constant to return each time
public static <T> Factory<T> constantFactory(T constantToReturn)
T - the type of the constant
constantToReturn - the constant object to return each time in the factory
constant factory.
public T create()
public T getConstant()