public static class UpdaterSettings.Builder extends Object
| Modifier and Type | Method and Description |
|---|---|
UpdaterSettings.Builder |
addCustomLogic(Map<String,List<Consumer<YamlDocument>>> consumers)
Adds custom logic to run on the document, per version ID.
|
UpdaterSettings.Builder |
addCustomLogic(String versionId,
Collection<Consumer<YamlDocument>> consumers)
Adds custom logic to run on the document at the provided version ID.
|
UpdaterSettings.Builder |
addCustomLogic(String versionId,
Consumer<YamlDocument> consumer)
Adds custom logic to run on the document at the provided version ID.
|
UpdaterSettings.Builder |
addIgnoredRoute(String versionId,
Route route)
Adds a route to ignore if updating to the provided version ID.
|
UpdaterSettings.Builder |
addIgnoredRoute(String versionId,
String route,
char separator)
Adds a route to ignore if updating to the provided version ID.
|
UpdaterSettings.Builder |
addIgnoredRoutes(Map<String,Set<Route>> routes)
Adds routes to ignore if updating to a certain version ID.
|
UpdaterSettings.Builder |
addIgnoredRoutes(Map<String,Set<String>> routes,
char separator)
Adds routes to ignore if updating to a certain version ID.
|
UpdaterSettings.Builder |
addIgnoredRoutes(String versionId,
Set<Route> routes)
Adds routes to ignore if updating to the provided version ID.
|
UpdaterSettings.Builder |
addIgnoredRoutes(String versionId,
Set<String> routes,
char separator)
Adds routes to ignore if updating to the provided version ID.
|
UpdaterSettings.Builder |
addMapper(String versionId,
Route route,
ValueMapper mapper)
Adds a mapper to apply to the given route at the provided version ID.
|
UpdaterSettings.Builder |
addMapper(String versionId,
String route,
ValueMapper mapper,
char separator)
Adds a mapper to apply to the given route at the provided version ID.
|
UpdaterSettings.Builder |
addMappers(Map<String,Map<Route,ValueMapper>> mappers)
Adds mappers to apply to their respective routes, per version ID.
|
UpdaterSettings.Builder |
addMappers(Map<String,Map<String,ValueMapper>> mappers,
char separator)
Adds mappers to apply to their respective routes, per version ID.
|
UpdaterSettings.Builder |
addMappers(String versionId,
Map<Route,ValueMapper> mappers)
Adds mappers to apply to their respective routes at the provided version ID.
|
UpdaterSettings.Builder |
addMappers(String versionId,
Map<String,ValueMapper> mappers,
char separator)
Adds mappers to apply to their respective routes at the provided version ID.
|
UpdaterSettings.Builder |
addRelocation(String versionId,
Route fromRoute,
Route toRoute)
Adds a relocation that took effect at the provided version ID.
|
UpdaterSettings.Builder |
addRelocation(String versionId,
String fromRoute,
String toRoute,
char separator)
Adds a relocation that took effect at the provided version ID.
|
UpdaterSettings.Builder |
addRelocations(Map<String,Map<Route,Route>> relocations)
Adds relocations (in
from route = to route format) per version ID, at which they took effect. |
UpdaterSettings.Builder |
addRelocations(Map<String,Map<String,String>> relocations,
char separator)
Adds relocations (in
from route = to route format) per version ID, at which they took effect. |
UpdaterSettings.Builder |
addRelocations(String versionId,
Map<Route,Route> relocations)
Adds relocations (in
from route = to route format) that took effect at the provided version ID. |
UpdaterSettings.Builder |
addRelocations(String versionId,
Map<String,String> relocations,
char separator)
Adds relocations (in
from route = to route format) that took effect at the provided version ID. |
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)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
UpdaterSettings.Builder |
setIgnoredRoutes(String versionId,
Set<Route> routes)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
UpdaterSettings.Builder |
setIgnoredStringRoutes(Map<String,Set<String>> routes)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
UpdaterSettings.Builder |
setIgnoredStringRoutes(String versionId,
Set<String> routes)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
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 |
setOptionSorting(UpdaterSettings.OptionSorting optionSorting)
Sets how to sort options in sections during merging.
|
UpdaterSettings.Builder |
setRelocations(Map<String,Map<Route,Route>> relocations)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
UpdaterSettings.Builder |
setRelocations(String versionId,
Map<Route,Route> relocations)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
UpdaterSettings.Builder |
setStringRelocations(Map<String,Map<String,String>> relocations)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
UpdaterSettings.Builder |
setStringRelocations(String versionId,
Map<String,String> relocations)
Deprecated.
Method with confusing name, use
addX() instead of setX(). Subject for
removal. |
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 setOptionSorting(@NotNull UpdaterSettings.OptionSorting optionSorting)
optionSorting - option sorting to usepublic 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 rule@Deprecated public UpdaterSettings.Builder setIgnoredRoutes(@NotNull Map<String,Set<Route>> routes)
addX() instead of setX(). Subject for
removal.@Deprecated public UpdaterSettings.Builder setIgnoredRoutes(@NotNull String versionId, @NotNull Set<Route> routes)
addX() instead of setX(). Subject for
removal.@Deprecated public UpdaterSettings.Builder setIgnoredStringRoutes(@NotNull Map<String,Set<String>> routes)
addX() instead of setX(). Subject for
removal.@Deprecated public UpdaterSettings.Builder setIgnoredStringRoutes(@NotNull String versionId, @NotNull Set<String> routes)
addX() instead of setX(). Subject for
removal.public UpdaterSettings.Builder addIgnoredRoute(@NotNull String versionId, @NotNull Route route)
blocks and contents will be excluded from merging and will appear in
the updated document (no matter the merge rules).
Ignoring routes is generally useful for sections which users can freely extend and their content is not strictly defined. Effective if and only a versioning is specified.
versionId - the version IDroute - the route to ignorepublic UpdaterSettings.Builder addIgnoredRoutes(@NotNull String versionId, @NotNull Set<Route> routes)
blocks and contents will be excluded from merging and will appear in
the updated document (no matter the merge rules).
Ignoring routes is generally useful for sections which users can freely extend and their content is not strictly defined. Effective if and only a versioning is specified.
versionId - the version IDroutes - the routes to ignorepublic UpdaterSettings.Builder addIgnoredRoutes(@NotNull Map<String,Set<Route>> routes)
blocks and contents will be excluded from merging and will appear in
the updated document (no matter the merge rules).
Ignoring routes is generally useful for sections which users can freely extend and their content is not strictly defined. Effective if and only a versioning is specified.
routes - the routes to ignore, per version IDpublic UpdaterSettings.Builder addIgnoredRoute(@NotNull String versionId, @NotNull String route, char separator)
blocks and contents will be excluded from merging and will appear in
the updated document (no matter the merge rules).
Ignoring routes is generally useful for sections which users can freely extend and their content is not strictly defined. Effective if and only a versioning is specified.
versionId - the version IDroute - the route to ignoreseparator - separator used to parse the routepublic UpdaterSettings.Builder addIgnoredRoutes(@NotNull String versionId, @NotNull Set<String> routes, char separator)
blocks and contents will be excluded from merging and will appear in
the updated document (no matter the merge rules).
Ignoring routes is generally useful for sections which users can freely extend and their content is not strictly defined. Effective if and only a versioning is specified.
versionId - the version IDroutes - the routes to ignoreseparator - separator used to parse the routespublic UpdaterSettings.Builder addIgnoredRoutes(@NotNull Map<String,Set<String>> routes, char separator)
blocks and contents will be excluded from merging and will appear in
the updated document (no matter the merge rules).
Ignoring routes is generally useful for sections which users can freely extend and their content is not strictly defined. Effective if and only a versioning is specified.
routes - the routes to ignore, per version IDseparator - separator used to parse the routes@Deprecated public UpdaterSettings.Builder setRelocations(@NotNull Map<String,Map<Route,Route>> relocations)
addX() instead of setX(). Subject for
removal.@Deprecated public UpdaterSettings.Builder setRelocations(@NotNull String versionId, @NotNull Map<Route,Route> relocations)
addX() instead of setX(). Subject for
removal.@Deprecated public UpdaterSettings.Builder setStringRelocations(@NotNull Map<String,Map<String,String>> relocations)
addX() instead of setX(). Subject for
removal.@Deprecated public UpdaterSettings.Builder setStringRelocations(@NotNull String versionId, @NotNull Map<String,String> relocations)
addX() instead of setX(). Subject for
removal.public UpdaterSettings.Builder addRelocation(@NotNull String versionId, @NotNull Route fromRoute, @NotNull Route toRoute)
Relocations represent that some mapping was moved from route x to y, which implies no content loss while updating. The ID at which a relocation took effect is the ID of the document which included the changes. If there is already a relocation defined for the version ID which is from the provided route, it is overwritten.
Relocations are useful if you moved something in the document to another place. Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDfromRoute - route from which a mapping was relocatedtoRoute - route to which the mapping was relocatedpublic UpdaterSettings.Builder addRelocations(@NotNull String versionId, @NotNull Map<Route,Route> relocations)
from route = to route format) that took effect at the provided version ID.
Relocations represent that some mapping was moved from route x to y, which implies no content loss while updating. The ID at which a relocation took effect is the ID of the document which included the changes. If there is already a relocation defined for the version ID and for a from route contained within the given map, it is overwritten.
Relocations are useful if you moved something in the document to another place. Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDrelocations - relocations which took effect at the version IDpublic UpdaterSettings.Builder addRelocations(@NotNull Map<String,Map<Route,Route>> relocations)
from route = to route format) per version ID, at which they took effect.
Relocations represent that some mapping was moved from route x to y, which implies no content loss while updating. The ID at which a relocation took effect is the ID of the document which included the changes. If there is already a relocation defined for a version ID and from route contained within the given map, it is overwritten.
Relocations are useful if you moved something in the document to another place. Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
relocations - the relocations, per version IDpublic UpdaterSettings.Builder addRelocation(@NotNull String versionId, @NotNull String fromRoute, @NotNull String toRoute, char separator)
Relocations represent that some mapping was moved from route x to y, which implies no content loss while updating. The ID at which a relocation took effect is the ID of the document which included the changes. If there is already a relocation defined for the version ID which is from the provided route, it is overwritten.
Relocations are useful if you moved something in the document to another place. Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDfromRoute - route from which a mapping was relocatedtoRoute - route to which the mapping was relocatedseparator - separator used to parse the routespublic UpdaterSettings.Builder addRelocations(@NotNull String versionId, @NotNull Map<String,String> relocations, char separator)
from route = to route format) that took effect at the provided version ID.
Relocations represent that some mapping was moved from route x to y, which implies no content loss while updating. The ID at which a relocation took effect is the ID of the document which included the changes. If there is already a relocation defined for the version ID and for a from route contained within the given map, it is overwritten.
Relocations are useful if you moved something in the document to another place. Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDrelocations - relocations which took effect at the version IDseparator - separator used to parse the routespublic UpdaterSettings.Builder addRelocations(@NotNull Map<String,Map<String,String>> relocations, char separator)
from route = to route format) per version ID, at which they took effect.
Relocations represent that some mapping was moved from route x to y, which implies no content loss while updating. The ID at which a relocation took effect is the ID of the document which included the changes. If there is already a relocation defined for a version ID and from route contained within the given map, it is overwritten.
Relocations are useful if you moved something in the document to another place. Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
relocations - the relocations, per version IDseparator - separator used to parse the routespublic UpdaterSettings.Builder addMapper(@NotNull String versionId, @NotNull Route route, @NotNull ValueMapper mapper)
Mappers can be used to map (= transform) a value at a route, to different value or from one type to another (for example from a boolean to an enum). The ID at which to apply a mapper is the ID of the document which included the datatype change. If there is already a mapper defined for the version ID and the provided route, it is overwritten.
Mappers are useful if you decided to change a value to represent the same, but using another datatype (for example, you now have a multi-constant enum for which was previously only true/false setting). Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDroute - route to apply the mapper atmapper - mapper to apply at the version IDpublic UpdaterSettings.Builder addMappers(@NotNull String versionId, @NotNull Map<Route,ValueMapper> mappers)
Mappers can be used to map (= transform) a value at a route, to different value or from one type to another (for example from a boolean to an enum). The ID at which to apply a mapper is the ID of the document which included the datatype change. If there is already a mapper defined for the version ID and for a route contained within the given map, it is overwritten.
Mappers are useful if you decided to change a value to represent the same, but using another datatype (for example, you now have a multi-constant enum for which was previously only true/false setting). Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDmappers - mappers to apply at the version IDpublic UpdaterSettings.Builder addMappers(@NotNull Map<String,Map<Route,ValueMapper>> mappers)
Mappers can be used to map (= transform) a value at a route, to different value or from one type to another (for example from a boolean to an enum). The ID at which to apply a mapper is the ID of the document which included the datatype change. If there is already a mapper defined for a version ID and route contained within the given map, it is overwritten.
Mappers are useful if you decided to change a value to represent the same, but using another datatype (for example, you now have a multi-constant enum for which was previously only true/false setting). Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
mappers - the mappers, per version IDpublic UpdaterSettings.Builder addMapper(@NotNull String versionId, @NotNull String route, @NotNull ValueMapper mapper, char separator)
Mappers can be used to map (= transform) a value at a route, to different value or from one type to another (for example from a boolean to an enum). The ID at which to apply a mapper is the ID of the document which included the datatype change. If there is already a mapper defined for the version ID and the provided route, it is overwritten.
Mappers are useful if you decided to change a value to represent the same, but using another datatype (for example, you now have a multi-constant enum for which was previously only true/false setting). Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDroute - route to apply the mapper atmapper - mapper to apply at the version IDseparator - separator used to parse the routespublic UpdaterSettings.Builder addMappers(@NotNull String versionId, @NotNull Map<String,ValueMapper> mappers, char separator)
Mappers can be used to map (= transform) a value at a route, to different value or from one type to another (for example from a boolean to an enum). The ID at which to apply a mapper is the ID of the document which included the datatype change. If there is already a mapper defined for the version ID and for a route contained within the given map, it is overwritten.
Mappers are useful if you decided to change a value to represent the same, but using another datatype (for example, you now have a multi-constant enum for which was previously only true/false setting). Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDmappers - mappers to apply at the version IDseparator - separator used to parse the routespublic UpdaterSettings.Builder addMappers(@NotNull Map<String,Map<String,ValueMapper>> mappers, char separator)
Mappers can be used to map (= transform) a value at a route, to different value or from one type to another (for example from a boolean to an enum). The ID at which to apply a mapper is the ID of the document which included the datatype change. If there is already a mapper defined for a version ID and route contained within the given map, it is overwritten.
Mappers are useful if you decided to change a value to represent the same, but using another datatype (for example, you now have a multi-constant enum for which was previously only true/false setting). Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
mappers - the mappers, per version IDseparator - separator used to parse the routespublic UpdaterSettings.Builder addCustomLogic(@NotNull String versionId, @NotNull Consumer<YamlDocument> consumer)
You can use your own logic to make changes to the document which are not available via the ignored routes, relocations or mappers. The order in which the consumers are run is undefined and may vary.
Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDconsumer - consumer to runpublic UpdaterSettings.Builder addCustomLogic(@NotNull Map<String,List<Consumer<YamlDocument>>> consumers)
You can use your own logic to make changes to the document which are not available via the ignored routes, relocations or mappers. The order in which the consumers are run is undefined and may vary.
Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
consumers - consumers to run, per version IDpublic UpdaterSettings.Builder addCustomLogic(@NotNull String versionId, @NotNull Collection<Consumer<YamlDocument>> consumers)
You can use your own logic to make changes to the document which are not available via the ignored routes, relocations or mappers. The order in which the consumers are run is undefined and may vary.
Effective if and only a versioning is specified.
Updating cycle for each version ID in the corresponding range (first to last): relocations -> mappers -> custom logic.
versionId - the version IDconsumers - consumers to run 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 © 2024. All rights reserved.