Package org.uncommons.maths.number
Class AdjustableNumberGenerator<T extends Number>
java.lang.Object
org.uncommons.maths.number.AdjustableNumberGenerator<T>
- Type Parameters:
T
- The type of number generated by this number generator.
- All Implemented Interfaces:
NumberGenerator<T>
public class AdjustableNumberGenerator<T extends Number>
extends Object
implements NumberGenerator<T>
Implementation of
NumberGenerator
that works similarly to
ConstantGenerator
but allows the returned
value to be changed after instantiation.
The most useful application of this type of number generator is to permit
runtime re-configuration of objects that rely on NumberGenerator
s
for their parameters. This can be achieved by creating UI components (e.g.
sliders and spinners) that invoke setValue(Number)
when their state
changes.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
lock
-
value
-
-
Constructor Details
-
AdjustableNumberGenerator
- Parameters:
value
- The initial value returned by all invocations ofnextValue()
(until it is modified by a call tosetValue(Number)
.
-
-
Method Details
-
setValue
Change the value that is returned by this generator.- Parameters:
value
- The new value to return.
-
nextValue
- Specified by:
nextValue
in interfaceNumberGenerator<T extends Number>
- Returns:
- The next value from the generator.
-