Class SimpleValueSource<K,V>
java.lang.Object
io.github.projectunified.valuevenue.common.SimpleValueSource<K,V>
- Type Parameters:
K- type of the keyV- type of the value
- All Implemented Interfaces:
ValueSource<K,,V> Function<K,List<V>>
A
ValueSource whose values are a fixed list of values, exposed as a single variable.
The variable resolves to the formatted value, while getSourceValueStream() exposes the values as they are,
so the formatter only decides what a template sees.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleValueSource(String key, Collection<V> values, Function<V, Object> formatter) Creates the source.SimpleValueSource(Collection<V> values, Function<V, Object> formatter) Creates the source withDEFAULT_KEY. -
Method Summary
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
-
SimpleValueSource
Creates the source withDEFAULT_KEY.- Parameters:
values- the values to exposeformatter- the formatting of a value to the replacement of the variable
-
SimpleValueSource
Creates the source.- Parameters:
key- name of the variable holding the valuevalues- the values to exposeformatter- the formatting of a value to the replacement of the variable
-
-
Method Details
-
replace
Description copied from interface:ValueSourceResolves a variable of the source value.- Specified by:
replacein interfaceValueSource<K,V> - 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
-
getSourceValueStream
Description copied from interface:ValueSourceAll source values that do not depend on a key.Empty by default: a source that only knows its values through
ValueSource.getSourceValueStream(Object)needs no override.- Specified by:
getSourceValueStreamin interfaceValueSource<K,V> - Returns:
- stream of every key-independent source value
-