Interface UnmodifiableConfig

All Known Subinterfaces:
CommentedConfig, CommentedFileConfig, Config, FileConfig, UnmodifiableCommentedConfig
All Known Implementing Classes:
AbstractCommentedConfig, AbstractConfig, CommentedConfigWrapper, ConfigWrapper, ConvertedCommentedConfig, ConvertedCommentedFileConfig, ConvertedConfig, ConvertedFileConfig, FakeCommentedConfig, FakeUnmodifiableCommentedConfig, UnmodifiableConfigWrapper

public interface UnmodifiableConfig
An unmodifiable (read-only) configuration that contains key/value mappings.
  • Method Details

    • get

      default <T> T get(String path)
      Gets a value from the config.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      Returns:
      the value at the given path, or null if there is no such value.
    • get

      default <T> T get(List<String> path)
      Gets a value from the config.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      Returns:
      the value at the given path, or null if there is no such value.
    • getRaw

      default <T> T getRaw(String path)
      Gets a value from the config. Doesn't convert NullObject.NULL_OBJECT to null.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      Returns:
      the value at the given path, or null if there is no such value.
    • getRaw

      <T> T getRaw(List<String> path)
      Gets a value from the config. Doesn't convert NullObject.NULL_OBJECT to null.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      Returns:
      the value at the given path, or null if there is no such value.
    • getOptional

      default <T> Optional<T> getOptional(String path)
      Gets an optional value from the config.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      Returns:
      an Optional containing the value at the given path, or Optional.empty() if there is no such value.
    • getOptional

      default <T> Optional<T> getOptional(List<String> path)
      Gets an optional value from the config.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      Returns:
      an Optional containing the value at the given path, or Optional.empty() if there is no such value.
    • getOrElse

      default <T> T getOrElse(String path, T defaultValue)
      Gets a value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      defaultValue - the default value to return if not found
      Returns:
      the value at the given path, or the default value if not found.
    • getOrElse

      default <T> T getOrElse(List<String> path, T defaultValue)
      Gets a value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      defaultValue - the default value to return if not found
      Returns:
      the value at the given path, or the default value if not found.
    • getOrElse

      default <T> T getOrElse(List<String> path, Supplier<T> defaultValueSupplier)
      Gets a value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      defaultValueSupplier - the Supplier of the default value
      Returns:
      the value at the given path, or the default value if not found.
    • getOrElse

      default <T> T getOrElse(String path, Supplier<T> defaultValueSupplier)
      Gets a value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      defaultValueSupplier - the Supplier of the default value
      Returns:
      the value at the given path, or the default value if not found.
    • getEnum

      default <T extends Enum<T>> T getEnum(String path, Class<T> enumType, EnumGetMethod method)
      Gets an Enum value from the config. If the value doesn't exist, returns null.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      enumType - the class of the Enum
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getEnum

      default <T extends Enum<T>> T getEnum(String path, Class<T> enumType)
    • getEnum

      default <T extends Enum<T>> T getEnum(List<String> path, Class<T> enumType, EnumGetMethod method)
      Gets an Enum value from the config. If the value doesn't exist, returns null.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      enumType - the class of the Enum
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getEnum

      default <T extends Enum<T>> T getEnum(List<String> path, Class<T> enumType)
    • getOptionalEnum

      default <T extends Enum<T>> Optional<T> getOptionalEnum(String path, Class<T> enumType, EnumGetMethod method)
      Gets an optional Enum value from the config.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      enumType - the class of the Enum
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getOptionalEnum

      default <T extends Enum<T>> Optional<T> getOptionalEnum(String path, Class<T> enumType)
    • getOptionalEnum

      default <T extends Enum<T>> Optional<T> getOptionalEnum(List<String> path, Class<T> enumType, EnumGetMethod method)
      Gets an optional Enum value from the config.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      enumType - the class of the Enum
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getOptionalEnum

      default <T extends Enum<T>> Optional<T> getOptionalEnum(List<String> path, Class<T> enumType)
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(String path, T defaultValue, EnumGetMethod method)
      Gets an Enum value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      defaultValue - the default value
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(String path, T defaultValue)
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(List<String> path, T defaultValue, EnumGetMethod method)
      Gets an Enum value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      defaultValue - the default value
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(List<String> path, T defaultValue)
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(String path, Class<T> enumType, EnumGetMethod method, Supplier<T> defaultValueSupplier)
      Gets an Enum value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      defaultValueSupplier - Supplier of the default value, only used if needed
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(String path, Class<T> enumType, Supplier<T> defaultValueSupplier)
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(List<String> path, Class<T> enumType, EnumGetMethod method, Supplier<T> defaultValueSupplier)
      Gets an Enum value from the config. If the value doesn't exist, returns the default value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      defaultValueSupplier - Supplier of the default value, only used if needed
      method - the method to use when converting a non-enum value like a String or an int
      Returns:
      the value at the given path as an enum, or null value if not found.
      Throws:
      IllegalArgumentException - if the config contains a String that doesn't match any of the enum constants, with regards to the given method
      ClassCastException - if the config contains a value that cannot be converted to an enum constant, like a List
    • getEnumOrElse

      default <T extends Enum<T>> T getEnumOrElse(List<String> path, Class<T> enumType, Supplier<T> defaultValueSupplier)
    • getInt

      default int getInt(String path)
      Like get(String) but returns a primitive int. The config's value must be a Number.
    • getInt

      default int getInt(List<String> path)
      Like get(List) but returns a primitive int. The config's value must be a Number.
    • getOptionalInt

      default OptionalInt getOptionalInt(String path)
      Like getOptional(String) but returns a primitive int. The config's value must be a Number or null or nonexistant.
    • getOptionalInt

      default OptionalInt getOptionalInt(List<String> path)
      Like getOptional(List) but returns a primitive int. The config's value must be a Number or null or nonexistant.
    • getIntOrElse

      default int getIntOrElse(String path, int defaultValue)
      Like getOrElse(String, Object) but returns a primitive int. The config's value must be a Number or null or nonexistant.
    • getIntOrElse

      default int getIntOrElse(List<String> path, int defaultValue)
      Like getOrElse(List, Object) but returns a primitive int. The config's value must be a Number or null or nonexistant.
    • getIntOrElse

      default int getIntOrElse(String path, IntSupplier defaultValueSupplier)
      Like getOrElse(String, Supplier) but returns a primitive int. The config's value must be a Number or null or nonexistant.
    • getIntOrElse

      default int getIntOrElse(List<String> path, IntSupplier defaultValueSupplier)
      Like getOrElse(List, Supplier) but returns a primitive int. The config's value must be a Number or null or nonexistant.
    • getLong

      default long getLong(String path)
      Like get(String) but returns a primitive long. The config's value must be a Number.
    • getLong

      default long getLong(List<String> path)
      Like get(List) but returns a primitive long. The config's value must be a Number.
    • getOptionalLong

      default OptionalLong getOptionalLong(String path)
      Like getOptional(String) but returns a primitive long. The config's value must be a Number or null or nonexistant.
    • getOptionalLong

      default OptionalLong getOptionalLong(List<String> path)
      Like getOptional(List) but returns a primitive long. The config's value must be a Number or null or nonexistant.
    • getLongOrElse

      default long getLongOrElse(String path, long defaultValue)
      Like getOrElse(String, Object) but returns a primitive long. The config's value must be a Number or null or nonexistant.
    • getLongOrElse

      default long getLongOrElse(List<String> path, long defaultValue)
      Like getOrElse(List, Object) but returns a primitive long. The config's value must be a Number or null or nonexistant.
    • getLongOrElse

      default long getLongOrElse(String path, LongSupplier defaultValueSupplier)
      Like getOrElse(String, Supplier) but returns a primitive long. The config's value must be a Number or null or nonexistant.
    • getLongOrElse

      default long getLongOrElse(List<String> path, LongSupplier defaultValueSupplier)
      Like getOrElse(List, Supplier) but returns a primitive long. The config's value must be a Number or null or nonexistant.
    • getByte

      default byte getByte(String path)
    • getByte

      default byte getByte(List<String> path)
    • getByteOrElse

      default byte getByteOrElse(String path, byte defaultValue)
    • getByteOrElse

      default byte getByteOrElse(List<String> path, byte defaultValue)
    • getShort

      default short getShort(String path)
    • getShort

      default short getShort(List<String> path)
    • getShortOrElse

      default short getShortOrElse(String path, short defaultValue)
    • getShortOrElse

      default short getShortOrElse(List<String> path, short defaultValue)
    • getChar

      default char getChar(String path)
      Returns a char value from the configuration.

      If the value is a Number, returns Number.intValue(), cast to char. If the value is a CharSequence, returns its first character. Otherwise, attempts to cast the value to a char.

      Parameters:
      path - the value's path as a dot-separated String
      Returns:
      the value, as a single char
    • getChar

      default char getChar(List<String> path)
      Returns a char value from the configuration.

      If the value is a Number, returns Number.intValue(), cast to char. If the value is a CharSequence, returns its first character. Otherwise, attempts to cast the value to a char.

      Parameters:
      path - the value's path as a list of String
      Returns:
      the value, as a single char
    • getCharOrElse

      default char getCharOrElse(String path, char defaultValue)
      Returns a char value from the configuration.

      If the value is nonexistant, returns defaultValue. If the value is a Number, returns Number.intValue(), cast to char. If the value is a CharSequence, returns its first character. Otherwise, attempts to cast the value to a char.

      Parameters:
      path - the value's path
      defaultValue - the char to return if the value doesn't exist in the config
      Returns:
      the value, as a single char
    • getCharOrElse

      default char getCharOrElse(List<String> path, char defaultValue)
      Returns a char value from the configuration.

      If the value is nonexistant, returns defaultValue. If the value is a Number, returns Number.intValue(), cast to char. If the value is a CharSequence, returns its first character. Otherwise, attempts to cast the value to a char.

      Parameters:
      path - the value's path
      defaultValue - the char to return if the value doesn't exist in the config
      Returns:
      the value, as a single char
    • contains

      default boolean contains(String path)
      Checks if the config contains a value at some path.
      Parameters:
      path - the path to check, each part separated by a dot. Example "a.b.c"
      Returns:
      true if the path is associated with a value, false if it's not.
    • contains

      boolean contains(List<String> path)
      Checks if the config contains a value at some path.
      Parameters:
      path - the path to check, each element of the list is a different part of the path.
      Returns:
      true if the path is associated with a value, false if it's not.
    • isNull

      default boolean isNull(String path)
      Checks if the config contains a null value at some path.
      Parameters:
      path - the path to check, each part separated by a dot. Example "a.b.c"
      Returns:
      true if the path is associated with NullObject.NULL_OBJECT, false if it's associated with another value or with no value.
    • isNull

      default boolean isNull(List<String> path)
      Checks if the config contains a null value at some path.
      Parameters:
      path - the path to check, each element of the list is a different part of the path.
      Returns:
      true if the path is associated with NullObject.NULL_OBJECT, false if it's associated with another value or with no value.
    • size

      int size()
      Gets the size of the config.
      Returns:
      the number of top-level elements in the config.
    • isEmpty

      default boolean isEmpty()
      Checks if the config is empty.
      Returns:
      true if the config is empty, false if it contains at least one element.
    • valueMap

      Map<String,Object> valueMap()
      Returns a Map view of the config's values. If the config is unmodifiable then the returned map is unmodifiable too.
      Returns:
      a Map view of the config's values.
    • entrySet

      Set<? extends UnmodifiableConfig.Entry> entrySet()
      Returns a Set view of the config's entries. If the config is unmodifiable then the returned set is unmodifiable too.
      Returns:
      a Set view of the config's entries.
    • configFormat

      ConfigFormat<?> configFormat()
      Returns the config's format.
      Returns:
      the config's format
    • apply

      default <T> T apply(String path)
      For scala: gets a config value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each part separated by a dot. Example "a.b.c"
      See Also:
    • apply

      default <T> T apply(List<String> path)
      For scala: gets a config value.
      Type Parameters:
      T - the value's type
      Parameters:
      path - the value's path, each element of the list is a different part of the path.
      See Also: