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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CcreateConcurrentConfig()Creates a config of this format.default CcreateConfig()CcreateConfig(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator)Creates a config that uses the given map supplier for all its levels (top level and subconfigs).ConfigParser<C>createParser()ConfigWritercreateWriter()default voidinitEmptyFile(WriterSupplier ws)Initializes an empty configuration file so that it can be parsed to an empty configuration.default voidinitEmptyFile(java.io.File f)Initializes an empty configuration file so that it can be parsed to an empty configuration.default voidinitEmptyFile(java.nio.file.Path f)Initializes an empty configuration file so that it can be parsed to an empty configuration.default booleanisInMemory()Checks if this format is in memory only and therefore cannot create writers nor parsers.booleansupportsComments()Checks if this format supports CommentedConfigs.default booleansupportsType(java.lang.Class<?> type)Checks if this format supports the given type of value.
-
-
-
Method Detail
-
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(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.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:
trueiff this format supports CommentedConfigs
-
supportsType
default boolean supportsType(java.lang.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:
trueiff 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:
trueiff this format is only in memory.
-
initEmptyFile
default void initEmptyFile(java.nio.file.Path f) throws java.io.IOExceptionInitializes 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:
java.io.IOException
-
initEmptyFile
default void initEmptyFile(java.io.File f) throws java.io.IOExceptionInitializes 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:
java.io.IOException
-
initEmptyFile
default void initEmptyFile(WriterSupplier ws) throws java.io.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:
java.io.IOException
-
-