Top Description Fields Constructors Methods
org.apache.commons.collections4.functors

public Class ConstantFactory<T>

extends Object
implements Factory<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.collections4.Factory
Imports
java.io.Serializable, org.apache.commons.collections4.Factory

Factory implementation that returns the same constant each time.

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.

Since
3.0

Field Summary

Modifier and TypeField and Description
private final T
iConstant

The closures to call in turn

public static final Factory<T>
NULL_INSTANCE

Returns null each time

private static final long
serialVersionUID

Serial version UID

Constructor Summary

AccessConstructor and Description
public
ConstantFactory(final T
the constant to return each time
constantToReturn
)

Constructor that performs no validation.

Method Summary

Modifier and TypeMethod and Description
public static <
the type of the constant
T
>
Factory<T>

Returns:

the constant factory.
constantFactory
(final T
the constant object to return each time in the factory
constantToReturn
)

Factory method that performs validation.

public T

Returns:

the stored constant value
create
()

Implements org.apache.commons.collections4.Factory.create.

Always return constant.
public T

Returns:

the constant
getConstant
()

Gets the constant.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iConstantback to summary
private final T iConstant

The closures to call in turn

NULL_INSTANCEback to summary
public static final Factory<T> NULL_INSTANCE

Returns null each time

Annotations
@SuppressWarnings:rawtypes
serialVersionUIDback to summary
private static final long serialVersionUID

Serial version UID

Constructor Detail

ConstantFactoryback to summary
public ConstantFactory(final T constantToReturn)

Constructor that performs no validation. Use constantFactory if you want that.

Parameters
constantToReturn:T

the constant to return each time

Method Detail

constantFactoryback to summary
public static <T> Factory<T> constantFactory(final T constantToReturn)

Factory method that performs validation.

Parameters
<T>
the type of the constant
constantToReturn:T

the constant object to return each time in the factory

Returns:Factory<T>

the constant factory.

createback to summary
public T create()

Implements org.apache.commons.collections4.Factory.create.

Always return constant.

Returns:T

the stored constant value

Annotations
@Override
getConstantback to summary
public T getConstant()

Gets the constant.

Returns:T

the constant

Since
3.1