Class AbstractConfigurationFormat<N extends ScopedConfigurationNode<N>,L extends AbstractConfigurationLoader<N>,B extends AbstractConfigurationLoader.Builder<B,L>>
- java.lang.Object
-
- org.spongepowered.configurate.loader.AbstractConfigurationFormat<N,L,B>
-
- Type Parameters:
N- the node typeL- the loader typeB- the builder type
- All Implemented Interfaces:
ConfigurationFormat
public abstract class AbstractConfigurationFormat<N extends ScopedConfigurationNode<N>,L extends AbstractConfigurationLoader<N>,B extends AbstractConfigurationLoader.Builder<B,L>> extends java.lang.Object implements ConfigurationFormat
An implementation ofConfigurationFormatdesigned to work withAbstractConfigurationLoader.This reduces the boilerplate that would otherwise be required to implement a configuration format service.
- Since:
- 4.2.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConfigurationFormat(java.lang.String id, java.util.function.Supplier<B> builderMaker, java.util.Set<java.lang.String> supportedExtensions)Create a new configuration format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigurationLoader<?>create(java.net.URL url)Create a new loader configured to load from the provided URL, with default style options.ConfigurationLoader<?>create(java.net.URL url, ConfigurationNode options)Create a new loader configured to load from the provided URL.ConfigurationLoader<?>create(java.nio.file.Path file)Create a new loader configured to load from the provided file, with default style options.ConfigurationLoader<?>create(java.nio.file.Path file, ConfigurationNode options)Create a new loader configured to load from the provided file.java.lang.Stringid()An identifier describing this loader.java.util.Set<java.lang.String>supportedExtensions()Get the file extensions known to be supported by this format.
-
-
-
Constructor Detail
-
AbstractConfigurationFormat
protected AbstractConfigurationFormat(java.lang.String id, java.util.function.Supplier<B> builderMaker, java.util.Set<java.lang.String> supportedExtensions)
Create a new configuration format.Subclasses should have a zero-argument constructor to fulfil the requirements of
ServiceLoader.- Parameters:
builderMaker- a factory creating a new buildersupportedExtensions- the file extensions associated with this format- Since:
- 4.2.0
-
-
Method Detail
-
id
public java.lang.String id()
Description copied from interface:ConfigurationFormatAn identifier describing this loader.This should match the naming used in other locations, such as the loader's artifact ID or class name.
- Specified by:
idin interfaceConfigurationFormat- Returns:
- the loader identifier
-
supportedExtensions
public java.util.Set<java.lang.String> supportedExtensions()
Description copied from interface:ConfigurationFormatGet the file extensions known to be supported by this format.- Specified by:
supportedExtensionsin interfaceConfigurationFormat- Returns:
- the supported extensions
-
create
public ConfigurationLoader<?> create(java.nio.file.Path file)
Description copied from interface:ConfigurationFormatCreate a new loader configured to load from the provided file, with default style options.- Specified by:
createin interfaceConfigurationFormat- Parameters:
file- the file to load from- Returns:
- a newly configured loader
-
create
public ConfigurationLoader<?> create(java.nio.file.Path file, ConfigurationNode options)
Description copied from interface:ConfigurationFormatCreate a new loader configured to load from the provided file.- Specified by:
createin interfaceConfigurationFormat- Parameters:
file- the file to load fromoptions- the options to use to configure the node- Returns:
- a newly configured loader
-
create
public ConfigurationLoader<?> create(java.net.URL url)
Description copied from interface:ConfigurationFormatCreate a new loader configured to load from the provided URL, with default style options.This loader may not be able to write to the given URL
- Specified by:
createin interfaceConfigurationFormat- Parameters:
url- the URL to load from- Returns:
- a newly configured loader
-
create
public ConfigurationLoader<?> create(java.net.URL url, ConfigurationNode options)
Description copied from interface:ConfigurationFormatCreate a new loader configured to load from the provided URL.This loader may not be able to write to the given URL.
- Specified by:
createin interfaceConfigurationFormat- Parameters:
url- the URL to load fromoptions- the options to use to configure the node- Returns:
- a newly configured loader
-
-