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 java.lang.Object implements ConfigurationFormat
An implementation ofConfigurationFormat
designed 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 protected
AbstractConfigurationFormat(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<? extends @NonNull java.lang.Object>
create(java.net.URL url)
Create a new loader configured to load from the provided URL, with default style options.ConfigurationLoader<? extends @NonNull java.lang.Object>
create(java.net.URL url, ConfigurationNode options)
Create a new loader configured to load from the provided URL.ConfigurationLoader<? extends @NonNull java.lang.Object>
create(java.nio.file.Path file)
Create a new loader configured to load from the provided file, with default style options.ConfigurationLoader<? extends @NonNull java.lang.Object>
create(java.nio.file.Path file, ConfigurationNode options)
Create a new loader configured to load from the provided file.java.lang.String
id()
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: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
public java.util.Set<java.lang.String> 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
public ConfigurationLoader<? extends @NonNull java.lang.Object> create(java.nio.file.Path file)
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
public ConfigurationLoader<? extends @NonNull java.lang.Object> create(java.nio.file.Path file, ConfigurationNode options)
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
public ConfigurationLoader<? extends @NonNull java.lang.Object> create(java.net.URL url)
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
public ConfigurationLoader<? extends @NonNull java.lang.Object> create(java.net.URL url, ConfigurationNode options)
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
-
-