Package org.uncommons.maths.number
Class ConstantGenerator<T extends java.lang.Number>
- java.lang.Object
-
- org.uncommons.maths.number.ConstantGenerator<T>
-
- Type Parameters:
T
- The numeric type (Integer, Long, Double, etc.) of the constant.
- All Implemented Interfaces:
NumberGenerator<T>
public class ConstantGenerator<T extends java.lang.Number> extends java.lang.Object implements NumberGenerator<T>
Convenience implementation ofNumberGenerator
that always returns the same value.
-
-
Constructor Summary
Constructors Constructor Description ConstantGenerator(T constant)
Creates a number generator that always returns the same values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
nextValue()
-
-
-
Field Detail
-
constant
private final T extends java.lang.Number constant
-
-
Constructor Detail
-
ConstantGenerator
public ConstantGenerator(T constant)
Creates a number generator that always returns the same values.- Parameters:
constant
- The value to be returned by all invocations of thenextValue()
method.
-
-
Method Detail
-
nextValue
public T nextValue()
- Specified by:
nextValue
in interfaceNumberGenerator<T extends java.lang.Number>
- Returns:
- The constant value specified when the generator was constructed.
-
-