java.io.Serializable, Factory<T>public class ConstantFactory<T> extends java.lang.Object implements Factory<T>, java.io.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 | Description |
|---|---|---|
static Factory |
NULL_INSTANCE |
Returns null each time
|
| Constructor | Description |
|---|---|
ConstantFactory(T constantToReturn) |
Constructor that performs no validation.
|
| Modifier and Type | Method | Description |
|---|---|---|
static <T> Factory<T> |
constantFactory(T constantToReturn) |
Factory method that performs validation.
|
T |
create() |
Always return constant.
|
T |
getConstant() |
Gets the constant.
|
public static final Factory NULL_INSTANCE
public ConstantFactory(T constantToReturn)
constantFactory if you want that.constantToReturn - the constant to return each timepublic static <T> Factory<T> constantFactory(T constantToReturn)
T - the type of the constantconstantToReturn - the constant object to return each time in the factoryconstant factory.public T create()
public T getConstant()
Copyright © 2001-2019 - Apache Software Foundation