Class DynamicNumberValueSource<K,N extends Number>
java.lang.Object
io.github.projectunified.valuevenue.number.DynamicNumberValueSource<K,N>
- Type Parameters:
K- type of the keyN- type of the number
- All Implemented Interfaces:
ValueSource<K,,N> Function<K,List<N>>
- Direct Known Subclasses:
NumberValueSource
public abstract class DynamicNumberValueSource<K,N extends Number>
extends Object
implements ValueSource<K,N>
A
ValueSource whose values are a range of numbers, with the start, the end and the step of the range
selected for each key.
The variable is DEFAULT_KEY unless another key is given to the constructor, and resolves to the plain text
of the number.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDynamicNumberValueSource(NumberType<N> type) Creates the source withDEFAULT_KEY, including the end.protectedDynamicNumberValueSource(NumberType<N> type, String key, boolean maxInclusive, Direction direction) Creates the source. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract NumberThe last value of the range of the key, or its bound when the end is not included.getSourceValueStream(K key) Source values to expose for the given key.protected abstract NumberThe first value of the range of the key.protected abstract NumberThe distance between two values of the range of the key, positive.Resolves a variable of the source value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.projectunified.valuevenue.core.ValueSource
apply, getSourceValueStream, isSourceValueActivated
-
Field Details
-
DEFAULT_KEY
The key used when none is given.- See Also:
-
-
Constructor Details
-
DynamicNumberValueSource
Creates the source withDEFAULT_KEY, including the end.- Parameters:
type- the number type of the values
-
DynamicNumberValueSource
protected DynamicNumberValueSource(NumberType<N> type, String key, boolean maxInclusive, Direction direction) Creates the source.- Parameters:
type- the number type of the valueskey- name of the variable holding the number itselfmaxInclusive- whether the end is a value of the rangedirection- the direction the values step in
-
-
Method Details
-
getStart
The first value of the range of the key.- Parameters:
key- the key- Returns:
- the first value
-
getEnd
The last value of the range of the key, or its bound when the end is not included.- Parameters:
key- the key- Returns:
- the last value
-
getStep
The distance between two values of the range of the key, positive.- Parameters:
key- the key- Returns:
- the step
-
getSourceValueStream
Description copied from interface:ValueSourceSource values to expose for the given key. Defaults toValueSource.getSourceValueStream().- Specified by:
getSourceValueStreamin interfaceValueSource<K,N extends Number> - Parameters:
key- key whose source values are requested- Returns:
- stream of source values for the key
-
replace
Description copied from interface:ValueSourceResolves a variable of the source value.- Specified by:
replacein interfaceValueSource<K,N extends Number> - Parameters:
input- name of the variable, without its markersvalue- source value the variable is resolved for- Returns:
- the replacement, or null if the variable is not known
-