Class StringSplitSource<K>
java.lang.Object
io.github.projectunified.valuevenue.common.StringSplitSource<K>
- Type Parameters:
K- type of the key
- All Implemented Interfaces:
ValueSource<K,,String> Function<K,List<String>>
A
ValueSource whose values are the pieces of a string, e.g. the lines of a setting.
The string is selected for each key by the source function and cut by the split pattern; a key without a string has
no value. The variable is DEFAULT_KEY unless another key is given to the constructor, and resolves to the
piece itself.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStringSplitSource(String key, Function<K, String> sourceFunction) Creates the source withDEFAULT_SPLIT_PATTERN.Creates the source.StringSplitSource(Function<K, String> sourceFunction) Creates the source withDEFAULT_KEYandDEFAULT_SPLIT_PATTERN.StringSplitSource(Function<K, String> sourceFunction, Pattern splitPattern) 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:
-
DEFAULT_SPLIT_PATTERN
The split pattern used when none is given: one value per line.
-
-
Constructor Details
-
StringSplitSource
Creates the source withDEFAULT_KEYandDEFAULT_SPLIT_PATTERN.- Parameters:
sourceFunction- the function selecting the string of a key
-
StringSplitSource
Creates the source withDEFAULT_KEY.- Parameters:
sourceFunction- the function selecting the string of a keysplitPattern- the pattern the string is cut by
-
StringSplitSource
Creates the source withDEFAULT_SPLIT_PATTERN.- Parameters:
key- name of the variable holding the piece itselfsourceFunction- the function selecting the string of a key
-
StringSplitSource
Creates the source.- Parameters:
key- name of the variable holding the piece itselfsourceFunction- the function selecting the string of a keysplitPattern- the pattern the string is cut by
-
-
Method Details
-
getSourceValueStream
Description copied from interface:ValueSourceSource values to expose for the given key. Defaults toValueSource.getSourceValueStream().- Specified by:
getSourceValueStreamin interfaceValueSource<K,String> - 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,String> - 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
-