Interface ConfigurationFormat
-
- All Known Implementing Classes:
AbstractConfigurationFormat
,GsonConfigurationFormat
,HoconConfigurationFormat
,JacksonConfigurationFormat
,XmlConfigurationFormat
,YamlConfigurationFormat
public interface ConfigurationFormat
A service provider interface declaring a specific configuration format.This is a service interface, designed to be implemented by modules that provide a
ConfigurationLoader
implementation. Service discovery follows the rules laid out inServiceLoader
.- Since:
- 4.2.0
- See Also:
AbstractConfigurationFormat
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default 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.default 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.static @Nullable ConfigurationFormat
forExtension(java.lang.String extension)
Get a configuration format that can handle the specified extension.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.static java.util.Set<ConfigurationFormat>
supportedFormats()
Get all supported configuration formats.
-
-
-
Method Detail
-
forExtension
static @Nullable ConfigurationFormat forExtension(java.lang.String extension)
Get a configuration format that can handle the specified extension.If a format fails to load, it will be ignored when p
- Parameters:
extension
- the extension to handle- Returns:
- a format, or
null
if none is known - Since:
- 4.2.0
-
supportedFormats
static java.util.Set<ConfigurationFormat> supportedFormats()
Get all supported configuration formats.If any exceptions were thrown while discovering or loading configuration format services, they will be rethrown on calling this method.
- Returns:
- all known formats
- Since:
- 4.2.0
-
id
java.lang.String id()
An identifier describing this loader.This should match the naming used in other locations, such as the loader's artifact ID or class name.
- Returns:
- the loader identifier
- Since:
- 4.2.0
-
supportedExtensions
java.util.Set<java.lang.String> supportedExtensions()
Get the file extensions known to be supported by this format.- Returns:
- the supported extensions
- Since:
- 4.2.0
-
create
default 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.- Parameters:
file
- the file to load from- Returns:
- a newly configured loader
- Since:
- 4.2.0
-
create
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.- Parameters:
file
- the file to load fromoptions
- the options to use to configure the node- Returns:
- a newly configured loader
- Since:
- 4.2.0
-
create
default 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.This loader may not be able to write to the given URL
- Parameters:
url
- the URL to load from- Returns:
- a newly configured loader
- Since:
- 4.2.0
-
create
ConfigurationLoader<? extends @NonNull java.lang.Object> create(java.net.URL url, ConfigurationNode options)
Create a new loader configured to load from the provided URL.This loader may not be able to write to the given URL.
- Parameters:
url
- the URL to load fromoptions
- the options to use to configure the node- Returns:
- a newly configured loader
- Since:
- 4.2.0
-
-