Interface ValueSource<K,SV>

Type Parameters:
K - type of the key
SV - type of the source value
All Superinterfaces:
Function<K,List<SV>>
All Known Implementing Classes:
BukkitPlayerSource, DynamicNumberValueSource, EnumValueSource, KeyValueSource, NumberValueSource, SimpleValueSource, StringSplitSource

public interface ValueSource<K,SV> extends Function<K,List<SV>>
The source values a value generator works on, before they are turned into final values.

A generator caches one final value per source value, so the source values are the identity of what is generated. They can depend on the key or be shared by every key.

It is a Function from a key to the active source values of that key, so it can be handed to a ValueVenue as it is.

  • Method Details

    • getSourceValueStream

      default Stream<SV> getSourceValueStream()
      All source values that do not depend on a key.

      Empty by default: a source that only knows its values through getSourceValueStream(Object) needs no override.

      Returns:
      stream of every key-independent source value
    • getSourceValueStream

      default Stream<SV> getSourceValueStream(K key)
      Source values to expose for the given key. Defaults to getSourceValueStream().
      Parameters:
      key - key whose source values are requested
      Returns:
      stream of source values for the key
    • isSourceValueActivated

      default boolean isSourceValueActivated(SV value)
      Whether a source value is currently active.
      Parameters:
      value - source value to check
      Returns:
      true if the value may be exposed
    • apply

      default List<SV> apply(K key)
      The source values exposed for the key: the stream of the key, without the inactive values.
      Specified by:
      apply in interface Function<K,SV>
      Parameters:
      key - key whose source values are requested
      Returns:
      list of the active source values for the key
    • replace

      Object replace(String input, SV value)
      Resolves a variable of the source value.
      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