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
- Direct Known Subclasses:
GsonConfigurationFormat
,HoconConfigurationFormat
,JacksonConfigurationFormat
,XmlConfigurationFormat
,YamlConfigurationFormat
public abstract class AbstractConfigurationFormat<N extends ScopedConfigurationNode<N>,L extends AbstractConfigurationLoader<N>,B extends AbstractConfigurationLoader.Builder<B,L>>
extends Object
implements ConfigurationFormat
An implementation of
ConfigurationFormat
designed to work
with AbstractConfigurationLoader
.
This reduces the boilerplate that would otherwise be required to implement a configuration format service.
- Since:
- 4.2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConfigurationLoader<? extends @NonNull Object>
Create a new loader configured to load from the provided URL, with default style options.ConfigurationLoader<? extends @NonNull Object>
create
(URL url, ConfigurationNode options) Create a new loader configured to load from the provided URL.ConfigurationLoader<? extends @NonNull Object>
Create a new loader configured to load from the provided file, with default style options.ConfigurationLoader<? extends @NonNull Object>
create
(Path file, ConfigurationNode options) Create a new loader configured to load from the provided file.id()
An identifier describing this loader.Get the file extensions known to be supported by this format.
-
Constructor Details
-
AbstractConfigurationFormat
protected AbstractConfigurationFormat(String id, Supplier<B> builderMaker, Set<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 Details
-
id
Description copied from interface:ConfigurationFormat
An 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:
id
in interfaceConfigurationFormat
- Returns:
- the loader identifier
-
supportedExtensions
Description copied from interface:ConfigurationFormat
Get the file extensions known to be supported by this format.- Specified by:
supportedExtensions
in interfaceConfigurationFormat
- Returns:
- the supported extensions
-
create
Description copied from interface:ConfigurationFormat
Create a new loader configured to load from the provided file, with default style options.- Specified by:
create
in interfaceConfigurationFormat
- Parameters:
file
- the file to load from- Returns:
- a newly configured loader
-
create
Description copied from interface:ConfigurationFormat
Create a new loader configured to load from the provided file.- Specified by:
create
in interfaceConfigurationFormat
- Parameters:
file
- the file to load fromoptions
- the options to use to configure the node- Returns:
- a newly configured loader
-
create
Description copied from interface:ConfigurationFormat
Create 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:
create
in interfaceConfigurationFormat
- Parameters:
url
- the URL to load from- Returns:
- a newly configured loader
-
create
Description copied from interface:ConfigurationFormat
Create a new loader configured to load from the provided URL.This loader may not be able to write to the given URL.
- Specified by:
create
in interfaceConfigurationFormat
- Parameters:
url
- the URL to load fromoptions
- the options to use to configure the node- Returns:
- a newly configured loader
-