Interface ConfigFormat<C extends Config>

Type Parameters:
C - the type of configurations created by this format
All Known Implementing Classes:
ConvertedFormat, InMemoryCommentedFormat, InMemoryFormat

public interface ConfigFormat<C extends Config>
A configuration format, that can parse, create and write some types of configurations.
  • Method Details

    • createWriter

      ConfigWriter createWriter()
      Returns:
      a writer of this config format
    • createParser

      ConfigParser<C> createParser()
      Returns:
      a parser of this config format
    • createConfig

      default C createConfig()
      Returns:
      a config of this format
    • createConcurrentConfig

      default C createConcurrentConfig()
      Creates a config of this format. The returned config is guaranteed to be thread-safe.
      Returns:
      a concurrent config of this format
    • createConfig

      C createConfig(Supplier<Map<String,Object>> mapCreator)
      Creates a config that uses the given map supplier for all its levels (top level and subconfigs).
      Parameters:
      mapCreator - the map supplier for the config
      Returns:
      a config of this format with the given map creator
    • supportsComments

      boolean supportsComments()
      Checks if this format supports CommentedConfigs. Note that supporting CommentedConfigs isn't the same things as allowing the user to write comments in the config files.
      Returns:
      true iff this format supports CommentedConfigs
    • supportsType

      default boolean supportsType(Class<?> type)
      Checks if this format supports the given type of value.
      Parameters:
      type - the type to check, may be null in which case this method checks if the format supports null values
      Returns:
      true iff this format supports the given type
    • isInMemory

      default boolean isInMemory()
      Checks if this format is in memory only and therefore cannot create writers nor parsers.
      Returns:
      true iff this format is only in memory.
    • initEmptyFile

      default void initEmptyFile(Path f) throws IOException
      Initializes an empty configuration file so that it can be parsed to an empty configuration. Does nothing by default.
      Parameters:
      f - the existing file to initialize
      Throws:
      IOException
    • initEmptyFile

      default void initEmptyFile(File f) throws IOException
      Initializes an empty configuration file so that it can be parsed to an empty configuration. Does nothing by default.
      Parameters:
      f - the existing file to initialize
      Throws:
      IOException
    • initEmptyFile

      default void initEmptyFile(WriterSupplier ws) throws IOException
      Initializes an empty configuration file so that it can be parsed to an empty configuration. Does nothing by default.
      Parameters:
      ws - an objet that provides a Writer to the file.
      Throws:
      IOException