Class EntryContainer

java.lang.Object
org.skriptlang.skript.lang.entry.EntryContainer

public class EntryContainer extends Object
An EntryContainer is a data container for obtaining the values of the entries of a SectionNode.
  • Method Details

    • withoutValidator

      public static EntryContainer withoutValidator(SectionNode source)
      Used for creating an EntryContainer when no EntryValidator exists.
      Parameters:
      source - The SectionNode to create a container for.
      Returns:
      An EntryContainer where all nodes will be getUnhandledNodes().
    • getSource

      public SectionNode getSource()
      Returns:
      The SectionNode containing the entries associated with this EntryValidator.
    • getUnhandledNodes

      public List<Node> getUnhandledNodes()
      Returns:
      Any nodes unhandled by the EntryValidator. The validator must have a node testing predicate for this list to contain any values. The 'unhandled node' would represent any entry provided by the user that the validator is not explicitly aware of.
    • get

      public <E, R extends E> R get(String key, Class<E> expectedType, boolean useDefaultValue)
      A method for obtaining a non-null, typed entry value. This method should ONLY be called if there is no way the entry could return null. In general, this means that the entry has a default value (and 'useDefaultValue' is true). This is because even though an entry may be required, parsing errors may occur that mean no value can be returned. It can also mean that the entry data is simple enough such that it will never return a null value.
      Parameters:
      key - The key associated with the entry.
      expectedType - The class representing the expected type of the entry's value.
      useDefaultValue - Whether the default value should be used if parsing failed.
      Returns:
      The entry's value.
      Throws:
      RuntimeException - If the entry's value is null, or if it is not of the expected type.
    • get

      public Object get(String key, boolean useDefaultValue)
      A method for obtaining a non-null entry value with an unknown type. This method should ONLY be called if there is no way the entry could return null. In general, this means that the entry has a default value (and 'useDefaultValue' is true). This is because even though an entry may be required, parsing errors may occur that mean no value can be returned. It can also mean that the entry data is simple enough such that it will never return a null value.
      Parameters:
      key - The key associated with the entry.
      useDefaultValue - Whether the default value should be used if parsing failed.
      Returns:
      The entry's value.
      Throws:
      RuntimeException - If the entry's value is null.
    • getOptional

      @Nullable public <E, R extends E> R getOptional(String key, Class<E> expectedType, boolean useDefaultValue)
      A method for obtaining a nullable, typed entry value.
      Parameters:
      key - The key associated with the entry.
      expectedType - The class representing the expected type of the entry's value.
      useDefaultValue - Whether the default value should be used if parsing failed.
      Returns:
      The entry's value. May be null if the entry is missing or a parsing error occurred.
      Throws:
      RuntimeException - If the entry's value is not of the expected type.
    • getOptional

      @Nullable public @Nullable Object getOptional(String key, boolean useDefaultValue)
      A method for obtaining a nullable entry value with an unknown type.
      Parameters:
      key - The key associated with the entry.
      useDefaultValue - Whether the default value should be used if parsing failed.
      Returns:
      The entry's value. May be null if the entry is missing or a parsing error occurred.