Class SimpleValueSource<K,V>

java.lang.Object
io.github.projectunified.valuevenue.common.SimpleValueSource<K,V>
Type Parameters:
K - type of the key
V - type of the value
All Implemented Interfaces:
ValueSource<K,V>, Function<K,List<V>>

public class SimpleValueSource<K,V> extends Object implements ValueSource<K,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 Details

  • Constructor Details

    • SimpleValueSource

      public SimpleValueSource(Collection<V> values, Function<V,Object> formatter)
      Creates the source with DEFAULT_KEY.
      Parameters:
      values - the values to expose
      formatter - the formatting of a value to the replacement of the variable
    • SimpleValueSource

      public SimpleValueSource(String key, Collection<V> values, Function<V,Object> formatter)
      Creates the source.
      Parameters:
      key - name of the variable holding the value
      values - the values to expose
      formatter - the formatting of a value to the replacement of the variable
  • Method Details

    • replace

      public Object replace(String input, V value)
      Description copied from interface: ValueSource
      Resolves a variable of the source value.
      Specified by:
      replace in interface ValueSource<K,V>
      Parameters:
      input - name of the variable, without its markers
      value - source value the variable is resolved for
      Returns:
      the replacement, or null if the variable is not known
    • getSourceValueStream

      public Stream<V> getSourceValueStream()
      Description copied from interface: ValueSource
      All 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:
      getSourceValueStream in interface ValueSource<K,V>
      Returns:
      stream of every key-independent source value