public static class UpdaterSettings.Builder extends Object
| Modifier and Type | Method and Description |
|---|---|
UpdaterSettings |
build()
Builds the settings.
|
UpdaterSettings.Builder |
setAutoSave(boolean autoSave)
Sets if the file should automatically be saved using
YamlDocument.save() after the updater has
finished updating (does not save if nothing's changed). |
UpdaterSettings.Builder |
setEnableDowngrading(boolean enableDowngrading)
Sets if to enable downgrading.
|
UpdaterSettings.Builder |
setIgnoredRoutes(Map<String,Set<Route>> routes)
Sets which blocks (represented by their routes) to ignore (including their contents) while updating to a
certain version ID.
|
UpdaterSettings.Builder |
setIgnoredRoutes(String versionId,
Set<Route> routes)
Sets which blocks (represented by their routes) to ignore (including their contents) while updating to the
specified version ID.
|
UpdaterSettings.Builder |
setIgnoredStringRoutes(Map<String,Set<String>> routes)
Sets which blocks (represented by their string routes) to ignore (including their contents) while
updating to a certain version ID.
|
UpdaterSettings.Builder |
setIgnoredStringRoutes(String versionId,
Set<String> routes)
Sets which blocks (represented by their string routes) to ignore (including their contents) while
updating to a certain version ID.
|
UpdaterSettings.Builder |
setKeepAll(boolean keepAll)
Sets if to keep all non-merged (that don't have an equivalent in the defaults) blocks in the document instead
of deleting them.
|
UpdaterSettings.Builder |
setMergeRule(MergeRule rule,
boolean preserveDocument)
Sets merge preservation rule and overwrites the already existing value for the given rule.
|
UpdaterSettings.Builder |
setMergeRules(Map<MergeRule,Boolean> mergeRules)
Sets merge preservation rules.
|
UpdaterSettings.Builder |
setRelocations(Map<String,Map<Route,Route>> relocations)
Sets relocations (in
from route = to route format) per version ID, at which they took place. |
UpdaterSettings.Builder |
setRelocations(String versionId,
Map<Route,Route> relocations)
Sets relocations (in
from route = to route format) that took effect at the given version ID. |
UpdaterSettings.Builder |
setStringRelocations(Map<String,Map<String,String>> relocations)
Sets relocations (in
from route = to route format) per version ID, at which they took place. |
UpdaterSettings.Builder |
setStringRelocations(String versionId,
Map<String,String> relocations)
Sets relocations (in
from route = to route format) that took effect at the given version ID. |
UpdaterSettings.Builder |
setVersioning(Pattern pattern,
Route route)
Sets versioning information.
|
UpdaterSettings.Builder |
setVersioning(Pattern pattern,
String route)
Sets versioning information.
|
UpdaterSettings.Builder |
setVersioning(Pattern pattern,
String documentVersionId,
String defaultsVersionId)
Sets versioning information.
|
UpdaterSettings.Builder |
setVersioning(Versioning versioning)
Sets versioning information.
|
public UpdaterSettings.Builder setAutoSave(boolean autoSave)
YamlDocument.save() after the updater has
finished updating (does not save if nothing's changed).
Not effective if there is no file associated with the document.
Default: UpdaterSettings.DEFAULT_AUTO_SAVE
autoSave - if to save automatically after updatepublic UpdaterSettings.Builder setEnableDowngrading(boolean enableDowngrading)
Downgrading is considered to be a situation:
If the updater detects downgrading, and it is enabled, the updater will skip relocations, proceeding directly
to merging; throws an error otherwise. If configured like so, you may also want to disable
LoaderSettings.Builder#setAutoUpdate(boolean) (if an error is thrown, you won't be able to create
the document).
Effective if and only a versioning is specified.
enableDowngrading - if to enable downgradingpublic UpdaterSettings.Builder setKeepAll(boolean keepAll)
Default: UpdaterSettings.DEFAULT_KEEP_ALL
keepAll - if to keep all non-merged blocks in the documentpublic UpdaterSettings.Builder setMergeRules(@NotNull Map<MergeRule,Boolean> mergeRules)
MergeRule.
The given map should contain the merge rule as the key, with value representing if to preserve content already in the document instead of the equivalent from defaults.
Default: UpdaterSettings.DEFAULT_MERGE_RULES
mergeRules - the merge rules to setsetMergeRule(MergeRule, boolean)public UpdaterSettings.Builder setMergeRule(@NotNull MergeRule rule, boolean preserveDocument)
MergeRule.
Default: UpdaterSettings.DEFAULT_MERGE_RULES
rule - the rule to setpreserveDocument - if to preserve content already in the document instead of the equivalent from
defaults for this rulepublic UpdaterSettings.Builder setIgnoredRoutes(@NotNull Map<String,Set<Route>> routes)
This is generally useful for sections which users can freely extend. In this sense, we can say that you should specify a version ID of the document and routes of such sections (which were in the document with the ID).
Effective if and only a versioning is specified.
routes - routes to ignore, per version IDsetIgnoredRoutes(String, Set)public UpdaterSettings.Builder setIgnoredRoutes(@NotNull String versionId, @NotNull Set<Route> routes)
This is generally useful for sections which users can freely extend. In this sense, we can say that you should specify a version ID of the document and routes of such sections (which were in the document with the ID).
Effective if and only a versioning is specified.
versionId - the version IDroutes - the set of routes representing blocks to ignore at the version IDpublic UpdaterSettings.Builder setIgnoredStringRoutes(@NotNull Map<String,Set<String>> routes)
This is generally useful for sections which users can freely extend. In this sense, we can say that you should specify a version ID of the document and routes of such sections (which were in the document with the ID).
Effective if and only a versioning is specified.
routes - string routes to ignore, per version IDsetIgnoredStringRoutes(String, Set)public UpdaterSettings.Builder setIgnoredStringRoutes(@NotNull String versionId, @NotNull Set<String> routes)
This is generally useful for sections which users can freely extend. In this sense, we can say that you should specify a version ID of the document and routes of such sections (which were in the document with the ID).
Effective if and only a versioning is specified.
versionId - the version IDroutes - the set of string routes representing blocks to ignore at the version IDpublic UpdaterSettings.Builder setRelocations(@NotNull Map<String,Map<Route,Route>> relocations)
from route = to route format) per version ID, at which they took place. If
there already are relocations defined for version ID which is also present in the given map, they are
overwritten.
Relocations define that some setting was moved from route x to y, enabling the updater to reproduce those steps without any content loss. The ID at which a relocation took effect is equal to ID of the file which included the changes.
Effective if and only a versioning is specified.
relocations - the relocations, per version IDsetRelocations(String, Map)public UpdaterSettings.Builder setRelocations(@NotNull String versionId, @NotNull Map<Route,Route> relocations)
from route = to route format) that took effect at the given version ID. If
there already are relocations defined for the version ID, they are overwritten.
Relocations define that some setting was moved from route x to y, enabling the updater to reproduce those steps without any content loss.The ID at which a relocation took effect is equal to ID of the file which included the changes.
Effective if and only a versioning is specified.
versionId - the version IDrelocations - relocations that took effect at the version IDpublic UpdaterSettings.Builder setStringRelocations(@NotNull Map<String,Map<String,String>> relocations)
from route = to route format) per version ID, at which they took place. If
there already are relocations defined for version ID which is also present in the given map, they are
overwritten.
Relocations define that some setting was moved from route x to y, enabling the updater to reproduce those steps without any content loss.The ID at which a relocation took effect is equal to ID of the file which included the changes.
Please note that all relocations will be merged when updating, with Route-based relocations
having higher priority.
Effective if and only a versioning is specified.
relocations - the relocations, per version IDsetStringRelocations(String, Map)public UpdaterSettings.Builder setStringRelocations(@NotNull String versionId, @NotNull Map<String,String> relocations)
from route = to route format) that took effect at the given version ID. If
there already are relocations defined for the version ID, they are overwritten.
Relocations define that some setting was moved from route x to y, enabling the updater to reproduce those steps without any content loss.The ID at which a relocation took effect is equal to ID of the file which included the changes.
Please note that all relocations will be merged when updating, with Route-based relocations
having higher priority.
Effective if and only a versioning is specified.
versionId - the version IDrelocations - relocations that took effect at the version IDpublic UpdaterSettings.Builder setVersioning(@NotNull Versioning versioning)
If the version ID of the defaults supplied by the versioning is null, it is considered illegal
and will throw a NullPointerException. If such value is returned for the document itself, the updater
will assign Versioning.getFirstVersion() to it. Please see the implementation documentation.
versioning - the versioningsetVersioning(Pattern, String, String),
setVersioning(Pattern, Route)public UpdaterSettings.Builder setVersioning(@NotNull Pattern pattern, @Nullable String documentVersionId, @NotNull String defaultsVersionId)
ManualVersioning(Pattern, String, String).pattern - the patterndocumentVersionId - version ID of the document that's being updateddefaultsVersionId - version ID of the defaultssetVersioning(Versioning)public UpdaterSettings.Builder setVersioning(@NotNull Pattern pattern, @NotNull Route route)
AutomaticVersioning(Pattern, Route).pattern - the patternroute - the route to version IDs (of both files)public UpdaterSettings.Builder setVersioning(@NotNull Pattern pattern, @NotNull String route)
AutomaticVersioning(Pattern, String).pattern - the patternroute - the route to version IDs (of both files)public UpdaterSettings build()
Copyright © 2022. All rights reserved.