public class ConstantFactory<T> extends Object implements 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<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 getConstant()
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.