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 forAbstractConfigurationLoaders.
-
-
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
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 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.In favour ofgetHeaderMode()@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 Detail
-
headerMode
protected @NonNull HeaderMode headerMode
-
source
protected @Nullable Callable<BufferedReader> source
-
sink
protected @Nullable Callable<BufferedWriter> sink
-
defaultOptions
protected @NonNull ConfigurationOptions defaultOptions
-
-
Constructor Detail
-
Builder
protected Builder()
-
-
Method Detail
-
setFile
public @NonNull T setFile(@NonNull 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)
-
setPath
public @NonNull T setPath(@NonNull 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)
-
setURL
public @NonNull T setURL(@NonNull 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)
-
setSource
public @NonNull T setSource(@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)
-
setSink
public @NonNull T setSink(@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)
-
getSource
public @Nullable Callable<BufferedReader> getSource()
Gets the source to be used by the resultant loader.- Returns:
- The source
-
getSink
public @Nullable Callable<BufferedWriter> getSink()
Gets the sink to be used by the resultant loader.- Returns:
- The sink
-
setHeaderMode
public @NonNull T setHeaderMode(@NonNull HeaderMode mode)
Sets the header mode of the resultant loader.- Parameters:
mode- The header mode- Returns:
- This builder (for chaining)
-
getHeaderMode
public @NonNull HeaderMode getHeaderMode()
Gets the header mode to be used by the resultant loader.- Returns:
- The header mode
-
setPreservesHeader
@Deprecated public @NonNull T setPreservesHeader(boolean preservesHeader)
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 public boolean preservesHeader()
Deprecated.In favour ofgetHeaderMode()Gets if the header of the configuration should be preserved.- Returns:
- If the header should be preserved
-
setDefaultOptions
public @NonNull T setDefaultOptions(@NonNull ConfigurationOptions defaultOptions)
Sets the default configuration options to be used by the resultant loader.- Parameters:
defaultOptions- The options- Returns:
- This builder (for chaining)
-
setDefaultOptions
public @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.- Parameters:
defaultOptions- to transform the existing default options- Returns:
- This builder (for chaining)
-
getDefaultOptions
public @NonNull ConfigurationOptions getDefaultOptions()
Gets the default configuration options to be used by the resultant loader.- Returns:
- The options
-
build
public abstract @NonNull AbstractConfigurationLoader<?> build()
Builds the loader.- Returns:
- The loader
-
-