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
AbstractConfigurationLoaders.-
Field Summary
Fields Modifier and Type Field Description protected @NonNull ConfigurationOptionsdefaultOptionsprotected @NonNull HeaderModeheaderModeprotected @Nullable Callable<BufferedWriter>sinkprotected @Nullable Callable<BufferedReader>source -
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder() -
Method Summary
Modifier and Type Method Description abstract @NonNull AbstractConfigurationLoader<?>build()Builds the loader.@NonNull ConfigurationOptionsgetDefaultOptions()Gets the default configuration options to be used by the resultant loader.@NonNull HeaderModegetHeaderMode()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.booleanpreservesHeader()Deprecated.@NonNull TsetDefaultOptions(@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 TsetDefaultOptions(@NonNull ConfigurationOptions defaultOptions)Sets the default configuration options to be used by the resultant loader.@NonNull TsetFile(@NonNull File file)Sets the sink and source of the resultant loader to the given file.@NonNull TsetHeaderMode(@NonNull HeaderMode mode)Sets the header mode of the resultant loader.@NonNull TsetPath(@NonNull Path path)Sets the sink and source of the resultant loader to the given path.@NonNull TsetPreservesHeader(boolean preservesHeader)Deprecated.In favour ofsetHeaderMode(HeaderMode)@NonNull TsetSink(@Nullable Callable<BufferedWriter> sink)Sets the sink of the resultant loader.@NonNull TsetSource(@Nullable Callable<BufferedReader> source)Sets the source of the resultant loader.@NonNull TsetURL(@NonNull URL url)Sets the source of the resultant loader to the given URL.
-
Field Details
-
headerMode
-
source
-
sink
-
defaultOptions
-
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
setFile
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)
-
setPath
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)
-
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.PRESERVEandHeaderMode.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
-
getHeaderMode()