Package ninja.leaping.configurate.loader
Class AbstractConfigurationLoader.Builder<T extends AbstractConfigurationLoader.Builder<T>>
java.lang.Object
ninja.leaping.configurate.loader.AbstractConfigurationLoader.Builder<T>
- Type Parameters:
T
- The builders own type (for chaining using generic types)
- Direct Known Subclasses:
GsonConfigurationLoader.Builder
,HoconConfigurationLoader.Builder
,JSONConfigurationLoader.Builder
,XMLConfigurationLoader.Builder
,YAMLConfigurationLoader.Builder
- Enclosing class:
- AbstractConfigurationLoader<NodeType extends ConfigurationNode>
protected abstract static class AbstractConfigurationLoader.Builder<T extends AbstractConfigurationLoader.Builder<T>> extends Object
An abstract builder implementation for
AbstractConfigurationLoader
s.-
Field Summary
Fields Modifier and Type Field Description protected @NonNull ConfigurationOptions
defaultOptions
protected @NonNull HeaderMode
headerMode
protected @Nullable Callable<BufferedWriter>
sink
protected @Nullable Callable<BufferedReader>
source
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
-
Method Summary
Modifier and Type Method Description abstract @NonNull AbstractConfigurationLoader<?>
build()
Builds the loader.@NonNull ConfigurationOptions
getDefaultOptions()
Gets the default configuration options to be used by the resultant loader.@NonNull HeaderMode
getHeaderMode()
Gets the header mode to be used by the resultant loader.@Nullable Callable<BufferedWriter>
getSink()
Gets the sink to be used by the resultant loader.@Nullable Callable<BufferedReader>
getSource()
Gets the source to be used by the resultant loader.boolean
preservesHeader()
Deprecated.In favour ofgetHeaderMode()
@NonNull T
setDefaultOptions(@NonNull 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 applicable changes.@NonNull T
setDefaultOptions(@NonNull ConfigurationOptions defaultOptions)
Sets the default configuration options to be used by the resultant loader.@NonNull T
setFile(@NonNull File file)
Sets the sink and source of the resultant loader to the given file.@NonNull T
setHeaderMode(@NonNull HeaderMode mode)
Sets the header mode of the resultant loader.@NonNull T
setPath(@NonNull Path path)
Sets the sink and source of the resultant loader to the given path.@NonNull T
setPreservesHeader(boolean preservesHeader)
Deprecated.In favour ofsetHeaderMode(HeaderMode)
@NonNull T
setSink(@Nullable Callable<BufferedWriter> sink)
Sets the sink of the resultant loader.@NonNull T
setSource(@Nullable Callable<BufferedReader> source)
Sets the source of the resultant loader.@NonNull T
setURL(@NonNull URL url)
Sets the source of the resultant loader to the given URL.
-
Field Details
-
Constructor Details
-
Method Details
-
setFile
Sets the sink and source of the resultant loader to the given file.The
source
is defined usingFiles.newBufferedReader(Path)
with UTF-8 encoding.The
sink
is defined usingAtomicFiles
with UTF-8 encoding.- Parameters:
file
- The configuration file- Returns:
- This builder (for chaining)
-
setPath
Sets the sink and source of the resultant loader to the given path.The
source
is defined usingFiles.newBufferedReader(Path)
with UTF-8 encoding.The
sink
is defined usingAtomicFiles
with UTF-8 encoding.- Parameters:
path
- The path of the configuration file- Returns:
- This builder (for chaining)
-
setURL
Sets the source of the resultant loader to the given URL.- Parameters:
url
- The URL of the source- Returns:
- This builder (for chaining)
-
setSource
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)
-
setSink
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)
-
getSource
Gets the source to be used by the resultant loader.- Returns:
- The source
-
getSink
Gets the sink to be used by the resultant loader.- Returns:
- The sink
-
setHeaderMode
Sets the header mode of the resultant loader.- Parameters:
mode
- The header mode- Returns:
- This builder (for chaining)
-
getHeaderMode
Gets the header mode to be used by the resultant loader.- Returns:
- The header mode
-
setPreservesHeader
Deprecated.In favour ofsetHeaderMode(HeaderMode)
Sets if the header of the configuration should be preserved.See
HeaderMode.PRESERVE
andHeaderMode.PRESET
.- Parameters:
preservesHeader
- If the header should be preserved- Returns:
- this builder (for chaining)
-
preservesHeader
Deprecated.In favour ofgetHeaderMode()
Gets if the header of the configuration should be preserved.- Returns:
- If the header should be preserved
-
setDefaultOptions
Sets the default configuration options to be used by the resultant loader.- Parameters:
defaultOptions
- The options- Returns:
- This builder (for chaining)
-
setDefaultOptions
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 applicable changes.- Parameters:
defaultOptions
- to transform the existing default options- Returns:
- This builder (for chaining)
-
getDefaultOptions
Gets the default configuration options to be used by the resultant loader.- Returns:
- The options
-
build
Builds the loader.- Returns:
- The loader
-