Class KeyValueEntryData<T>

java.lang.Object
org.skriptlang.skript.lang.entry.EntryData<T>
org.skriptlang.skript.lang.entry.KeyValueEntryData<T>
Type Parameters:
T - The type of the value.
Direct Known Subclasses:
ExpressionEntryData, LiteralEntryData, VariableStringEntryData

public abstract class KeyValueEntryData<T> extends EntryData<T>
An entry based on SimpleNodes containing a key and a value. Unlike a traditional EntryNode, this entry data may have a value that is not a String.
  • Constructor Details

    • KeyValueEntryData

      public KeyValueEntryData(String key, @Nullable T defaultValue, boolean optional)
  • Method Details

    • getValue

      @Nullable public final T getValue(Node node)
      Used to obtain and parse the value of a SimpleNode. This method accepts any type of node, but assumes the input to be a SimpleNode. Before calling this method, the caller should first check canCreateWith(Node) to make sure that the node is viable.
      Specified by:
      getValue in class EntryData<T>
      Parameters:
      node - A SimpleNode to obtain (and possibly convert) the value of.
      Returns:
      The value obtained from the provided SimpleNode.
    • getValue

      @Nullable protected abstract T getValue(String value)
      Parses a String value using this entry data.
      Parameters:
      value - The String value to parse.
      Returns:
      The parsed value.
    • getSeparator

      public String getSeparator()
      Returns:
      The String acting as a separator between the key and the value.
    • canCreateWith

      public boolean canCreateWith(Node node)
      Checks whether the provided node can have its value obtained using this entry data. A check is done to verify that the node is a SimpleNode, and that it starts with the necessary key.
      Specified by:
      canCreateWith in class EntryData<T>
      Parameters:
      node - The node to check.
      Returns:
      Whether the provided Node works with this entry data.