Class AbstractConfigurationLoader.Builder<T extends AbstractConfigurationLoader.Builder<T,L>,L extends AbstractConfigurationLoader<?>>
- java.lang.Object
-
- org.spongepowered.configurate.loader.AbstractConfigurationLoader.Builder<T,L>
-
- Type Parameters:
T- the builder's own type (for chaining using generic types)
- Direct Known Subclasses:
GsonConfigurationLoader.Builder,HoconConfigurationLoader.Builder,JacksonConfigurationLoader.Builder,XmlConfigurationLoader.Builder,YamlConfigurationLoader.Builder
- Enclosing class:
- AbstractConfigurationLoader<N extends ScopedConfigurationNode<N>>
public abstract static class AbstractConfigurationLoader.Builder<T extends AbstractConfigurationLoader.Builder<T,L>,L extends AbstractConfigurationLoader<?>> extends Object
An abstract builder implementation forAbstractConfigurationLoaders.- Since:
- 4.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected ConfigurationOptionsdefaultOptionsprotected HeaderModeheaderModeprotected @Nullable Callable<BufferedWriter>sinkprotected @Nullable Callable<BufferedReader>source
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()Create a new builder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Lbuild()Builds the loader.ConfigurationNodebuildAndLoadString(String input)Configure to read from a string, build, and load in one step.StringbuildAndSaveString(ConfigurationNode output)Configure to write to a string, build, and save in one step.ConfigurationOptionsdefaultOptions()Gets the default configuration options to be used by the resultant loader.TdefaultOptions(UnaryOperator<ConfigurationOptions> defaultOptions)Sets the default configuration options to be used by the resultant loader by providing a function which takes the current default options and applies any desired changes.TdefaultOptions(ConfigurationOptions defaultOptions)Sets the default configuration options to be used by the resultant loader.Tfile(File file)Sets the sink and source of the resultant loader to the given file.HeaderModeheaderMode()Gets the header mode to be used by the resultant loader.TheaderMode(HeaderMode mode)Sets the header mode of the resultant loader.Tpath(Path path)Sets the sink and source of the resultant loader to the given path.@Nullable Callable<BufferedWriter>sink()Gets the sink to be used by the resultant loader.Tsink(@Nullable Callable<BufferedWriter> sink)Sets the sink of the resultant loader.@Nullable Callable<BufferedReader>source()Gets the source to be used by the resultant loader.Tsource(@Nullable Callable<BufferedReader> source)Sets the source of the resultant loader.Turl(URL url)Sets the source of the resultant loader to the given URL.
-
-
-
Field Detail
-
headerMode
protected HeaderMode headerMode
-
source
protected @Nullable Callable<BufferedReader> source
-
sink
protected @Nullable Callable<BufferedWriter> sink
-
defaultOptions
protected ConfigurationOptions defaultOptions
-
-
Constructor Detail
-
Builder
protected Builder()
Create a new builder.This is where any custom default options can be applied.
- Since:
- 4.0.0
-
-
Method Detail
-
file
public T file(File file)
Sets the sink and source of the resultant loader to the given file.The
sourceis defined usingFiles.newBufferedReader(Path)with UTF-8 encoding.The
sinkis defined usingAtomicFileswith UTF-8 encoding.- Parameters:
file- the configuration file- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
path
public T path(Path path)
Sets the sink and source of the resultant loader to the given path.The
sourceis defined usingFiles.newBufferedReader(Path)with UTF-8 encoding.The
sinkis defined usingAtomicFileswith UTF-8 encoding.- Parameters:
path- the path of the configuration file- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
url
public T url(URL url)
Sets the source of the resultant loader to the given URL.- Parameters:
url- the URL of the source- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
source
public T source(@Nullable Callable<BufferedReader> source)
Sets the source of the resultant loader.The "source" is used by the loader to load the configuration.
- Parameters:
source- the source- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
source
public @Nullable Callable<BufferedReader> source()
Gets the source to be used by the resultant loader.- Returns:
- the source
- Since:
- 4.0.0
-
sink
public T sink(@Nullable Callable<BufferedWriter> sink)
Sets the sink of the resultant loader.The "sink" is used by the loader to save the configuration.
- Parameters:
sink- the sink- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
sink
public @Nullable Callable<BufferedWriter> sink()
Gets the sink to be used by the resultant loader.- Returns:
- the sink
- Since:
- 4.0.0
-
headerMode
public T headerMode(HeaderMode mode)
Sets the header mode of the resultant loader.- Parameters:
mode- the header mode- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
headerMode
public HeaderMode headerMode()
Gets the header mode to be used by the resultant loader.- Returns:
- the header mode
- Since:
- 4.0.0
-
defaultOptions
public T defaultOptions(ConfigurationOptions defaultOptions)
Sets the default configuration options to be used by the resultant loader.- Parameters:
defaultOptions- the options- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
defaultOptions
public T defaultOptions(UnaryOperator<ConfigurationOptions> defaultOptions)
Sets the default configuration options to be used by the resultant loader by providing a function which takes the current default options and applies any desired changes.- Parameters:
defaultOptions- to transform the existing default options- Returns:
- this builder (for chaining)
- Since:
- 4.0.0
-
defaultOptions
public ConfigurationOptions defaultOptions()
Gets the default configuration options to be used by the resultant loader.- Returns:
- the options
- Since:
- 4.0.0
-
buildAndLoadString
public ConfigurationNode buildAndLoadString(String input) throws ConfigurateException
Configure to read from a string, build, and load in one step.- Parameters:
input- the input to load- Returns:
- a deserialized node
- Throws:
ConfigurateException- Since:
- 4.1.0
-
buildAndSaveString
public String buildAndSaveString(ConfigurationNode output) throws ConfigurateException
Configure to write to a string, build, and save in one step.- Parameters:
output- the node to write- Returns:
- the output string
- Throws:
ConfigurateException- Since:
- 4.1.0
-
-