public abstract class GenericBuilder<Base extends Config,Result extends FileConfig>
extends java.lang.Object
charset(Charset)writingMode(WritingMode)parsingMode(ParsingMode)onFileNotFound(FileNotFoundAction)sync()autosave()autoreload()concurrent()Config.isInsertionOrderPreserved()
returns true when the builder is constructed.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoreload |
protected boolean |
autosave |
protected java.nio.charset.Charset |
charset |
protected boolean |
concurrent |
protected java.nio.file.Path |
file |
protected ConfigFormat<? extends Base> |
format |
protected boolean |
insertionOrder |
protected java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> |
mapCreator |
protected FileNotFoundAction |
nefAction |
protected ConfigParser<? extends Base> |
parser |
protected ParsingMode |
parsingMode |
protected boolean |
sync |
protected ConfigWriter |
writer |
protected WritingMode |
writingMode |
| Modifier and Type | Method and Description |
|---|---|
GenericBuilder<Base,Result> |
autoreload()
Makes the configuration "autoreloaded", that is, its
FileConfig.load() method is
automatically called when the file is modified. |
GenericBuilder<Base,Result> |
autosave()
Makes the configuration "autosaved", that is, its
FileConfig.save() method is
automatically called when it is modified. |
GenericBuilder<Base,Result> |
backingMapCreator(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> s)
Uses a specific Supplier to create the backing maps (one for the top level
and one for each sub-configuration) of the configuration.
|
Result |
build()
Creates a new FileConfig with the chosen settings.
|
protected abstract Result |
buildAutosave(FileConfig chain) |
protected abstract Result |
buildNormal(FileConfig chain) |
GenericBuilder<Base,Result> |
charset(java.nio.charset.Charset charset)
Sets the charset used for
FileConfig.save() and FileConfig.load(). |
GenericBuilder<Base,Result> |
concurrent()
Makes the configuration concurrent, that is, thread-safe.
|
GenericBuilder<Base,Result> |
defaultData(java.io.File file)
Sets the file to copy when the config's file is not found.
|
GenericBuilder<Base,Result> |
defaultData(java.nio.file.Path file)
Sets the file to copy when the config's file is not found.
|
GenericBuilder<Base,Result> |
defaultData(java.net.URL url)
Sets the URL of the data to copy when the config's file is not found.
|
GenericBuilder<Base,Result> |
defaultResource(java.lang.String resourcePath)
Sets the resource (in the jar) to copy when the config's file is not found.
|
protected Base |
getConfig() |
GenericBuilder<Base,Result> |
onFileNotFound(FileNotFoundAction nefAction)
Sets the action to execute when the config's file is not found.
|
GenericBuilder<Base,Result> |
parsingMode(ParsingMode parsingMode)
Sets the ParsingMode used for
FileConfig.load() |
GenericBuilder<Base,Result> |
preserveInsertionOrder()
Makes the configuration preserve the insertion order of its values.
|
GenericBuilder<Base,Result> |
sync()
Makes the configuration "write-synchronized", that is, its
FileConfig.save()
method blocks until the write operation completes. |
GenericBuilder<Base,Result> |
writingMode(WritingMode writingMode)
Sets the WritingMode used for
FileConfig.save() |
protected final java.nio.file.Path file
protected final ConfigFormat<? extends Base extends Config> format
protected final ConfigWriter writer
protected final ConfigParser<? extends Base extends Config> parser
protected java.nio.charset.Charset charset
protected WritingMode writingMode
protected ParsingMode parsingMode
protected FileNotFoundAction nefAction
protected boolean sync
protected boolean autosave
protected boolean autoreload
protected boolean concurrent
protected boolean insertionOrder
protected java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapCreator
public GenericBuilder<Base,Result> charset(java.nio.charset.Charset charset)
FileConfig.save() and FileConfig.load().public GenericBuilder<Base,Result> writingMode(WritingMode writingMode)
FileConfig.save()public GenericBuilder<Base,Result> parsingMode(ParsingMode parsingMode)
FileConfig.load()public GenericBuilder<Base,Result> onFileNotFound(FileNotFoundAction nefAction)
public GenericBuilder<Base,Result> defaultResource(java.lang.String resourcePath)
onFileNotFound(FileNotFoundAction.copyResource(resourcePath))resourcePath - the resource's pathpublic GenericBuilder<Base,Result> defaultData(java.io.File file)
onFileNotFound(FileNotFoundAction.copyData(file))file - the data filepublic GenericBuilder<Base,Result> defaultData(java.nio.file.Path file)
onFileNotFound(FileNotFoundAction.copyData(file))file - the data filepublic GenericBuilder<Base,Result> defaultData(java.net.URL url)
onFileNotFound(FileNotFoundAction.copyData(url))url - the data urlpublic GenericBuilder<Base,Result> sync()
FileConfig.save()
method blocks until the write operation completes.public GenericBuilder<Base,Result> autosave()
FileConfig.save() method is
automatically called when it is modified.public GenericBuilder<Base,Result> autoreload()
FileConfig.load() method is
automatically called when the file is modified.public GenericBuilder<Base,Result> concurrent()
public GenericBuilder<Base,Result> preserveInsertionOrder()
public GenericBuilder<Base,Result> backingMapCreator(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> s)
Warning : if autoreload() is called, the map creator
must return thread-safe maps, because the autoreloading system will modify
the configuration from another thread.
s - the map supplier to usepublic Result build()
protected abstract Result buildAutosave(FileConfig chain)
protected abstract Result buildNormal(FileConfig chain)
protected final Base getConfig()