Class EntryValidator.EntryValidatorBuilder

java.lang.Object
org.skriptlang.skript.lang.entry.EntryValidator.EntryValidatorBuilder
Enclosing class:
EntryValidator

public static class EntryValidator.EntryValidatorBuilder extends Object
A utility builder for creating an entry validator that can be used to parse and validate a SectionNode.
See Also:
  • Field Details

  • Method Details

    • entrySeparator

      public EntryValidator.EntryValidatorBuilder entrySeparator(String separator)
      Updates the separator to be used when creating KeyValue entries. Please note that this will not update the separator for already registered KeyValue entries.
      Parameters:
      separator - The new separator for KeyValue entries.
      Returns:
      The builder instance.
    • unexpectedNodeTester

      public EntryValidator.EntryValidatorBuilder unexpectedNodeTester(Predicate<Node> unexpectedNodeTester)
      A predicate to be supplied for checking whether a Node should be allowed even as an entry not declared in the entry data map. The default behavior is that the predicate returns true for every Node tested.
      Parameters:
      unexpectedNodeTester - The predicate to use.
      Returns:
      The builder instance.
    • unexpectedEntryMessage

      public EntryValidator.EntryValidatorBuilder unexpectedEntryMessage(Function<String,String> unexpectedEntryMessage)
      A function to be applied when an unexpected Node is encountered during validation. A String representing the user input (the Node's key) goes in, and an error message to output comes out.
      Parameters:
      unexpectedEntryMessage - The function to use.
      Returns:
      The builder instance.
    • missingRequiredEntryMessage

      public EntryValidator.EntryValidatorBuilder missingRequiredEntryMessage(Function<String,String> missingRequiredEntryMessage)
      A function to be applied when a required Node is missing during validation. A String representing the key of the missing entry goes in, and an error message to output comes out.
      Parameters:
      missingRequiredEntryMessage - The function to use.
      Returns:
      The builder instance.
    • addEntry

      public EntryValidator.EntryValidatorBuilder addEntry(String key, @Nullable String defaultValue, boolean optional)
      Adds a new KeyValueEntryData to this validator that returns the raw, unhandled String value. The added entry is optional and will use the provided default value as a backup.
      Parameters:
      key - The key of the entry.
      defaultValue - The default value of this entry to use if the user does not include this entry.
      Returns:
      The builder instance.
    • addSection

      public EntryValidator.EntryValidatorBuilder addSection(String key, boolean optional)
      Adds a new, potentially optional SectionEntryData to this validator.
      Parameters:
      key - The key of the section entry.
      optional - Whether this section entry should be optional.
      Returns:
      The builder instance.
    • addEntryData

      public EntryValidator.EntryValidatorBuilder addEntryData(EntryData<?> entryData)
      A method to add custom EntryData to a validator. Custom entry data should be preferred when the default methods included in this builder are not expansive enough. Please note that for custom KeyValueEntryData implementations, the default entry separator value of this builder will not be used. Instead, DEFAULT_ENTRY_SEPARATOR will be used.
      Parameters:
      entryData - The custom entry data to include in this validator.
      Returns:
      The builder instance.
    • build

      public EntryValidator build()
      Returns:
      The final, built entry validator.