### Example: managing comments on a block Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/comments.md Shows how to set, add, read, and remove comments on a block. The returned list from get() is live, so adding to it modifies the document. ```java Block block = config.getBlock("players.max"); // Put comments above the entry Comments.set(block, NodeRole.KEY, Comments.Position.BEFORE, Arrays.asList(Comments.create("Maximum number of players", Comments.Position.BEFORE), Comments.BLANK_LINE)); // Append an inline comment Comments.add(block, NodeRole.KEY, Comments.Position.INLINE, Comments.create("in seconds", Comments.Position.INLINE)); // Read them back List before = Comments.get(block, NodeRole.KEY, Comments.Position.BEFORE); if (before != null) { before.add(Comments.create("Another line", Comments.Position.BEFORE)); // live list } // Remove everything at the position Comments.remove(block, NodeRole.KEY, Comments.Position.AFTER); ``` -------------------------------- ### Manual versioning example with UpdaterSettings Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Example of creating UpdaterSettings with ManualVersioning, specifying a version pattern, document version ID "1.3", and defaults version ID "1.5". ```java // Manual versioning example UpdaterSettings settings = UpdaterSettings.builder() .setVersioning(new ManualVersioning(VERSION_PATTERN, "1.3", "1.5")) .build(); ``` -------------------------------- ### Route factory usage examples Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/route.md Example usage of the static factory methods. Shows how to create routes with multiple keys, a single key, parse from a string, and append a key to an existing route. ```java Route name = Route.from("players", "name"); // ["players", "name"] Route single = Route.fromSingleKey("level"); // ["level"] Route parsed = Route.fromString("a.b.c"); // ["a", "b", "c"] Route appended = Route.addTo(name, 5); // ["players", "name", 5] ``` -------------------------------- ### Version comparison and next() example Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Shows how to obtain Version instances from a Pattern and use compareTo() to compare versions and next() to advance to the next version. The comment notes that a negative compareTo result means v1 is older. ```java Version v1 = pattern.getVersion("1.2"); Version v2 = pattern.getVersion("1.5"); int c = v1.compareTo(v2); // negative → v1 older v1.next(); // "1.2" -> "1.3" ``` -------------------------------- ### Build GeneralSettings and create YamlDocument Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/generalsettings.md Example of building a GeneralSettings instance with a custom key format, route separator, and defaults, then creating a YamlDocument with it. `setKeyFormat(KeyFormat.OBJECT)` is required for Route-based access to non-string keys. ```java GeneralSettings settings = GeneralSettings.builder() .setKeyFormat(KeyFormat.OBJECT) // required for Route-based access to non-string keys .setRouteSeparator('/') .setUseDefaults(false) .setDefaultString("unknown") .build(); YamlDocument doc = YamlDocument.create(file, defaults, settings); ``` -------------------------------- ### Example version ID comments in YAML Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Shows how version IDs are specified in the document. The first release uses version 1, the second 2, and so on. ```yaml config-version: 1 # 1st release config-version: 2 # 2nd release config-version: 3 # 3rd release # etc. ``` -------------------------------- ### Create section methods and usage example Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Creates a section at the given route, creating all missing intermediate sections and overwriting non-section blocks while keeping their comments. Returns the existing section if already present. The example shows creating a "players" section and setting a value. ```java public Section createSection(@NotNull Route route) // line 882 public Section createSection(@NotNull String route) // line 905 ``` ```java Section players = config.createSection("players"); players.set("max", 100); ``` -------------------------------- ### Gradle shadow plugin configuration for relocating BoostedYAML Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Add this at the very start of your build.gradle file (Gradle 7.3) to enable the shadow plugin. Get your desired version from the provided link. ```gradle plugins { id 'com.gradleup.shadow' version '8.3.5' id 'java' } ``` -------------------------------- ### Block comment usage example Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/block.md Example usage of the comment convenience methods on a Block instance. ```java block.addComment("This is a comment block"); block.setComments(Arrays.asList("line1", "line2")); List comments = block.getComments(); block.removeComments(); ``` -------------------------------- ### Usage with defaults Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Example usage of typed getters with defaults. Demonstrates retrieving a string list, an integer with an explicit default, and a mapped values getter. ```java // Usage with defaults List names = config.getStringList("players.names"); int max = config.getInt("settings.max-players", 20); // explicit default Map all = config.getStringRouteMappedValues(true); ``` -------------------------------- ### RouteFactory usage example Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/route.md Example usage of RouteFactory with a custom separator '/'. Creates a route from the string "server/worlds/main" resulting in keys ["server", "worlds", "main"], and retrieves the separator. ```java RouteFactory factory = new RouteFactory('/'); Route r = factory.create("server/worlds/main"); // keys: ["server", "worlds", "main"] char sep = factory.getSeparator(); // '/' ``` -------------------------------- ### BasicVersioning Class Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Classic config-version scheme using a single integer starting at 1. ```APIDOC ## BasicVersioning Class ### Description The classic `config-version: 1` scheme (single integer starting at 1). ### Fields - **PATTERN** (Pattern) - `public static final Pattern PATTERN = new Pattern(Segment.range(1, Integer.MAX_VALUE))` ### Constructors - **BasicVersioning(@NotNull String route)** - Creates a BasicVersioning instance with the given route. ``` -------------------------------- ### get(String, Object) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Retrieves a value at the given string route, returning the specified default if not found. ```APIDOC ## get(String, Object) ### Description Retrieves a value at the given string route, returning the specified default if not found. ### Method GET ### Endpoint `get(String route, Object def)` ### Parameters #### Path Parameters - **route** (String) - Required - The route to the value. - **def** (Object) - Required - The default value to return if the route is not found. ### Response #### Success Response (200) - **Object** - The value if present, otherwise the default. #### Response Example ```java Object value = section.get("path.to.value", "default"); ``` ``` -------------------------------- ### Builder usage example Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Builds a LoaderSettings instance with auto-update enabled, file creation disabled, duplicate keys disallowed, and a code point limit of 1,000,000. Note: combining setEnableDowngrading(false) with setAutoUpdate(true) can throw during YamlDocument.create(...). ```java LoaderSettings loader = LoaderSettings.builder() .setAutoUpdate(true) // update against defaults on every load .setCreateFileIfAbsent(false) // do not create the file automatically .setAllowDuplicateKeys(false) .setCodePointLimit(1_000_000) .build(); ``` -------------------------------- ### Formatter lambda example for money Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/utils.md Example lambda implementing Formatter that returns DOUBLE_QUOTED style for string values ending with '$', otherwise def. ```java Formatter money = (tag, value, role, def) -> Tag.STR.equals(tag) && value.endsWith("$") ? ScalarStyle.DOUBLE_QUOTED : def; ``` -------------------------------- ### BasicVersioning constructor and pattern Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Implements the classic config-version: 1 scheme using a single integer starting at 1. The PATTERN field defines a range from 1 to Integer.MAX_VALUE. ```java public static final Pattern PATTERN = new Pattern(Segment.range(1, Integer.MAX_VALUE)); // line 30 public BasicVersioning(@NotNull String route) // line 37 ``` -------------------------------- ### get(Route, Object) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Retrieves a value at the given route, returning the specified default if not found. ```APIDOC ## get(Route, Object) ### Description Retrieves a value at the given route, returning the specified default if not found. ### Method GET ### Endpoint `get(Route route, Object def)` ### Parameters #### Path Parameters - **route** (Route) - Required - The route to the value. - **def** (Object) - Required - The default value to return if the route is not found. ### Response #### Success Response (200) - **Object** - The value if present, otherwise the default. #### Response Example ```java Object value = section.get(route, "default"); ``` ``` -------------------------------- ### Using ValueMapper with UpdaterSettings Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/updatersettings.md Example of adding a mapper for key '3' under 'enabled' that converts a boolean string to 'yes' or 'no'. ```java UpdaterSettings.builder() .addMapper("3", Route.from("enabled"), ValueMapper.value(enabled -> Boolean.parseBoolean(String.valueOf(enabled)) ? "yes" : "no")) .build(); ``` -------------------------------- ### Save with file association check Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/yamldocument.md Example of calling save() when a file is associated, handling the case where no file is associated by printing an error and suggesting alternatives. ```java // Save when a file is associated, handle failure if (config.save()) { System.out.println("Saved"); } else { System.err.println("No file associated — use save(File) or dump()"); } ``` -------------------------------- ### get(String) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Retrieves a value at the given string route. Returns the value if present, otherwise returns the default object or from defaults. ```APIDOC ## get(String) ### Description Retrieves a value at the given string route. Returns the value if present, otherwise returns the default object or from defaults. ### Method GET ### Endpoint `get(String route)` ### Parameters #### Path Parameters - **route** (String) - Required - The route to the value. ### Response #### Success Response (200) - **Object** - The value if present, otherwise default. #### Response Example ```java Object value = section.get("path.to.value"); ``` ``` -------------------------------- ### Pattern construction and version parsing Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Example of constructing a Pattern with segments for major, separator, and minor, and using getVersion to parse a version ID. The Javadoc recommends reserving a separator character as its own literal segment or using fixed-width range segments to avoid overlapping. ```java Pattern VERSION_PATTERN = new Pattern( Segment.range(1, Integer.MAX_VALUE), // major Segment.literal("."), // separator Segment.range(0, 10)); // minor Version v = VERSION_PATTERN.getVersion("1.4"); // non-null ``` -------------------------------- ### Build UpdaterSettings with versioning and operations Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/updatersettings.md Shows how to create UpdaterSettings using the builder, setting versioning, ignored routes, relocations, mappers, and custom logic, then using it to create a YamlDocument with auto-update enabled. ```java UpdaterSettings updater = UpdaterSettings.builder() .setVersioning(new BasicVersioning("config-version")) // auto versioning at the "config-version" route .addIgnoredRoute("2", Route.from("user-settings")) // users can freely extend this section .addRelocation("3", Route.from("old.path"), Route.from("new.path")) .addMapper("4", Route.from("difficulty"), ValueMapper.value(v -> "true".equalsIgnoreCase(String.valueOf(v)) ? Difficulty.HARD : Difficulty.EASY)) .addCustomLogic("5", doc -> doc.set("migrated-at", System.currentTimeMillis())) .build(); YamlDocument config = YamlDocument.create(file, defaults, GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, updater); ``` -------------------------------- ### Segment.range(int start, int end, int step, int fill) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Creates a range segment with full configuration: start inclusive, end exclusive, step, and fill for digit padding (fill <= 0 disables padding). ```APIDOC ## range(int start, int end, int step, int fill) ### Description Creates a range segment with full configuration: start inclusive, end exclusive, step, and fill for digit padding (fill <= 0 disables padding). ### Method range ### Signature `static Segment range(int start, int end, int step, int fill)` ### Parameters - **start** (int) - Required - The start of the range (inclusive). - **end** (int) - Required - The end of the range (exclusive). - **step** (int) - Required - The step between elements. - **fill** (int) - Required - Digit padding; <=0 disables padding. ### Returns - **Segment** - A range segment. ### Exceptions - **IllegalArgumentException** - If the range is invalid (step 0, empty range, wrong step direction, negative elements, fill too small for the largest element). ``` -------------------------------- ### YamlDocument.create with Settings varargs Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/configuration.md Shows the varargs signature for passing configuration settings to YamlDocument.create. The last instance of each settings type wins; missing types fall back to the type's DEFAULT. There are no configuration files or BoostedYAML environment variables. ```java YamlDocument.create(file, defaults, GeneralSettings..., LoaderSettings..., DumperSettings..., UpdaterSettings...); ``` -------------------------------- ### ManualVersioning Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Documentation for the ManualVersioning class, including its constructor and methods. ```APIDOC ## ManualVersioning ### Description Creates a manual versioning strategy for the updater, allowing explicit specification of the document and defaults version IDs. The document version ID can be null, in which case the updater assigns the first version. The defaults version ID must be parsable, otherwise the updater will reject it with a NullPointerException. ### Constructor `public ManualVersioning(@NotNull Pattern pattern, @Nullable String documentVersionId, @NotNull String defaultsVersionId)` ### Parameters - **pattern** (Pattern) - Required - The pattern used to parse version strings. - **documentVersionId** (String) - Optional - The version ID of the document; if null, the updater assigns the first version. - **defaultsVersionId** (String) - Required - The version ID of the defaults; must be parsable. ### Methods #### getDocumentVersion `public Version getDocumentVersion(@NotNull Section document, boolean defaults)` Returns the version of the document or defaults based on the `defaults` flag. If `defaults` is true and the defaults version ID is unparsable, returns null. #### getFirstVersion `public Version getFirstVersion()` Returns the first version defined by the pattern. ### Example ```java // Manual versioning example UpdaterSettings settings = UpdaterSettings.builder() .setVersioning(new ManualVersioning(VERSION_PATTERN, "1.3", "1.5")) .build(); ``` ``` -------------------------------- ### LoaderSettings.builder(LoaderSettings settings) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Creates a Builder preset from existing LoaderSettings. ```APIDOC ## LoaderSettings.builder(LoaderSettings settings) ### Description Creates a Builder preset from existing LoaderSettings. ### Method STATIC ### Endpoint LoaderSettings.builder(LoaderSettings settings) ### Parameters #### Path Parameters - **settings** (LoaderSettings) - Required - The settings to copy. ### Request Example ```java LoaderSettings existing = LoaderSettings.DEFAULT; LoaderSettings.builder(existing) ``` ### Response #### Success Response - **builder** (Builder) - A new Builder instance. #### Response Example ```java LoaderSettings.builder(existing) ``` ``` -------------------------------- ### Block Value Methods Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/block.md Methods to set and get the stored value of a Block. ```APIDOC ## Block Value Methods ### Description Sets or retrieves the value stored in the block. For Section, the stored value is a Map; for TerminatedBlock, it is a plain Object. ### Methods - `public void setValue(T value)` - line 191 - `public T getStoredValue()` - line 292 ### Parameters - `value` (T) - Required - The new value to set. ### Returns - `getStoredValue()` returns the stored value of type T. ### Usage ```java block.setValue("new value"); T value = block.getStoredValue(); ``` ``` -------------------------------- ### Creating a YamlDocument with defaults and settings Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/yamldocument.md Shows two ways to create a YamlDocument from a file with defaults. The basic usage copies defaults automatically on first run; the fully configured variant passes GeneralSettings, LoaderSettings with auto-update, DumperSettings, and UpdaterSettings with BasicVersioning. ```java // Basic usage YamlDocument config = YamlDocument.create(new File("plugins/MyPlugin/config.yml"), getResource("config.yml")); // defaults copied automatically on first run // Fully configured YamlDocument config = YamlDocument.create(new File("plugins/MyPlugin/config.yml"), getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build()); ``` -------------------------------- ### Reload cycle with settings visibility Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/yamldocument.md Demonstrates a reload cycle with settings visibility: reloads the config, reads a mode string, and sets a player max value. Shows how to use YamlDocument as a section. ```java // Reload cycle with settings visibility config.reload(); Mode mode = config.getOptionalString("mode") .map(s -> Mode.valueOf(s.toUpperCase())) .orElse(Mode.PERFORMANCE); config.set("players.max", 100); config.save(); ``` -------------------------------- ### getPart(int) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Deprecated method to get a segment by index. Use getSegment(int) instead. ```APIDOC ## getPart(int) ### Description Deprecated method to retrieve a segment by its index. Use getSegment(int) instead. ### Method Deprecated ### Signature ```java @Deprecated public Segment getPart(int index) ``` ### Parameters - **index** (int) - Required - The index of the segment to retrieve. ### Returns - **Segment** - The segment at the specified index. ``` -------------------------------- ### DumperSettings.buildEngineSettings() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dumpersettings.md Builds the underlying SnakeYAML Engine DumpSettings, forcing comment dumping and applying the configured anchor generator supplier. ```APIDOC ## [METHOD] buildEngineSettings ### Description Builds the underlying SnakeYAML Engine DumpSettings, forcing comment dumping and applying the configured anchor generator supplier. ### Method N/A (Java method) ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response - **DumpSettings** - The built Engine settings. #### Response Example ```java DumpSettings settings = dumperSettings.buildEngineSettings(); ``` ``` -------------------------------- ### Segment.range(int start, int end) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Creates a range segment with step of ±1 depending on the direction. ```APIDOC ## range(int start, int end) ### Description Creates a range segment with step of ±1 depending on the direction. ### Method range ### Signature `static Segment range(int start, int end)` ### Parameters - **start** (int) - Required - The start of the range (inclusive). - **end** (int) - Required - The end of the range (exclusive). ### Returns - **Segment** - A range segment. ### Exceptions - **IllegalArgumentException** - If the range is invalid. ``` -------------------------------- ### Instance methods of LoaderSettings Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Methods to query and build loader settings. isAutoUpdate() checks if YamlDocument.update() is auto-called after load; isCreateFileIfAbsent() checks if the file is created and saved when missing; buildEngineSettings(GeneralSettings) forces parse comments and wires collection suppliers; builder() and builder(LoadSettingsBuilder) create builders, with the latter wrapping an existing Engine builder without cloning; builder(LoaderSettings) presets from existing settings. ```java public boolean isAutoUpdate() // line 58 — auto-call YamlDocument.update() after load public boolean isCreateFileIfAbsent() // line 68 — create + save the file when missing public LoadSettings buildEngineSettings(GeneralSettings generalSettings) // line 79 public static Builder builder() // line 91 public static Builder builder(LoadSettingsBuilder builder) // line 106 — wrap an existing Engine builder (not cloned!) public static Builder builder(LoaderSettings settings) // line 120 — preset from existing settings ``` -------------------------------- ### LoaderSettings.builder() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Creates a new LoaderSettings.Builder instance. ```APIDOC ## LoaderSettings.builder() ### Description Creates a new Builder for constructing LoaderSettings instances. ### Method STATIC ### Endpoint LoaderSettings.builder() ### Parameters None ### Request Example ```java LoaderSettings.builder() ``` ### Response #### Success Response - **builder** (Builder) - A new Builder instance. #### Response Example ```java LoaderSettings.builder() ``` ``` -------------------------------- ### Segment.range(int start, int end, int step) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Creates a range segment without fill padding. ```APIDOC ## range(int start, int end, int step) ### Description Creates a range segment without fill padding. ### Method range ### Signature `static Segment range(int start, int end, int step)` ### Parameters - **start** (int) - Required - The start of the range (inclusive). - **end** (int) - Required - The end of the range (exclusive). - **step** (int) - Required - The step between elements. ### Returns - **Segment** - A range segment. ### Exceptions - **IllegalArgumentException** - If the range is invalid. ``` -------------------------------- ### DumperSettings.builder(DumperSettings settings) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dumpersettings.md Creates a new builder preset with the given DumperSettings. ```APIDOC ## [METHOD] builder(DumperSettings settings) ### Description Creates a new builder preset with the given DumperSettings. ### Method N/A (Java static method) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **settings** (DumperSettings) - Required - The settings to preset the builder with. ### Request Example ```java DumperSettings preset = DumperSettings.DEFAULT; DumperSettings.Builder builder = DumperSettings.builder(preset); ``` ### Response #### Success Response - **Builder** - A new builder instance. #### Response Example ```java DumperSettings.Builder builder = DumperSettings.builder(preset); ``` ``` -------------------------------- ### get(Route) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Retrieves a value at the given route. Returns the value if present, otherwise returns the default object or from defaults. ```APIDOC ## get(Route) ### Description Retrieves a value at the given route. Returns the value if present, otherwise returns the default object or from defaults. ### Method GET ### Endpoint `get(Route route)` ### Parameters #### Path Parameters - **route** (Route) - Required - The route to the value. ### Response #### Success Response (200) - **Object** - The value if present, otherwise default. #### Response Example ```java Object value = section.get(route); ``` ``` -------------------------------- ### LoaderSettings.Builder.build() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Builds the immutable LoaderSettings instance. ```APIDOC ## LoaderSettings.Builder.build() ### Description Builds the immutable LoaderSettings instance. ### Method INSTANCE ### Endpoint LoaderSettings.Builder.build() ### Parameters None ### Request Example ```java LoaderSettings loader = LoaderSettings.builder() .setAutoUpdate(true) .setCreateFileIfAbsent(false) .setAllowDuplicateKeys(false) .setCodePointLimit(1_000_000) .build(); ``` ### Response #### Success Response - **settings** (LoaderSettings) - The built settings. #### Response Example ```java LoaderSettings.builder().build() ``` ``` -------------------------------- ### Create a YamlDocument with defaults Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Creates a YamlDocument from a file and a default resource. The file is automatically created if missing and defaults are copied automatically. ```java YamlDocument config = YamlDocument.create(new File("config.yml"), getResource("config.yml")); ``` -------------------------------- ### UpdaterSettings Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/updatersettings.md Documentation for the UpdaterSettings class, including its constants, getters, and builder methods. ```APIDOC ## UpdaterSettings ### Description Immutable settings for the file updater: versioning, ignored routes, relocations, mappers, custom logic, merge rules and post-update behaviors. `UpdaterSettings.DEFAULT` is the default instance (auto-save on, downgrading on, no versioning). ### Public Constants - `DEFAULT_AUTO_SAVE` (boolean) - Default: `true` - `DEFAULT_ENABLE_DOWNGRADING` (boolean) - Default: `true` - `DEFAULT_KEEP_ALL` (boolean) - Default: `false` - `DEFAULT_OPTION_SORTING` (OptionSorting) - Default: `SORT_BY_DEFAULTS` - `DEFAULT_MERGE_RULES` (Map) - Default: `MAPPINGS → true`, `MAPPING_AT_SECTION → false`, `SECTION_AT_MAPPING → false` - `DEFAULT_VERSIONING` (Versioning) - Default: `null` ### Instance Getters #### getMergeRules ```java public Map getMergeRules() ``` Returns the merge rules. #### getIgnoredRoutes ```java public Set getIgnoredRoutes(@NotNull String versionId, char separator) ``` Returns the ignored routes for the given version. #### getRelocations ```java public Map getRelocations(@NotNull String versionId, char separator) ``` Returns the relocations for the given version. #### getMappers ```java public Map getMappers(@NotNull String versionId, char separator) ``` Returns the mappers for the given version. #### getCustomLogic ```java public List> getCustomLogic(@NotNull String versionId) ``` Returns the custom logic for the given version. #### getVersioning ```java public Versioning getVersioning() ``` Returns the versioning settings. #### isEnableDowngrading ```java public boolean isEnableDowngrading() ``` Returns whether downgrading is enabled. #### isKeepAll ```java public boolean isKeepAll() ``` Returns whether all entries are kept. #### isAutoSave ```java public boolean isAutoSave() ``` Returns whether auto-save is enabled. #### getOptionSorting ```java public OptionSorting getOptionSorting() ``` Returns the option sorting mode. ### Static Builder Methods #### builder ```java public static Builder builder() ``` Creates a new builder. #### builder(UpdaterSettings settings) ```java public static Builder builder(UpdaterSettings settings) ``` Creates a new builder based on the given settings. ### OptionSorting Enum | Constant | Meaning | |----------|---------| | `NONE` | Newly merged entries are appended last into the section map; no extra memory. | | `SORT_BY_DEFAULTS` | Entries end up in the order defined by the defaults (needs an order-preserving map supplier, e.g. `LinkedHashMap`). Default. | ``` -------------------------------- ### LoaderSettings.buildEngineSettings(GeneralSettings generalSettings) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Builds the underlying SnakeYAML Engine LoadSettings, forcing parse comments and wiring collection factories. ```APIDOC ## LoaderSettings.buildEngineSettings(GeneralSettings generalSettings) ### Description Builds the underlying SnakeYAML Engine LoadSettings, forcing parse comments and wiring collection factories from GeneralSettings. ### Method INSTANCE ### Endpoint LoaderSettings.buildEngineSettings(GeneralSettings generalSettings) ### Parameters #### Path Parameters - **generalSettings** (GeneralSettings) - Required - The general settings providing collection factories. ### Request Example ```java GeneralSettings general = GeneralSettings.builder().build(); LoaderSettings loader = LoaderSettings.DEFAULT; LoadSettings engineSettings = loader.buildEngineSettings(general); ``` ### Response #### Success Response - **engineSettings** (LoadSettings) - The built engine settings. #### Response Example ```java LoadSettings.builder().build() ``` ``` -------------------------------- ### DumperSettings.builder() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dumpersettings.md Creates a new builder for DumperSettings. ```APIDOC ## [METHOD] builder ### Description Creates a new builder for DumperSettings. ### Method N/A (Java static method) ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response - **Builder** - A new builder instance. #### Response Example ```java DumperSettings.Builder builder = DumperSettings.builder(); ``` ``` -------------------------------- ### Get value with functional getter Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Retrieves a string value using a functional getter, maps it to an enum, and falls back to PERFORMANCE if the value is absent or invalid. ```java Mode m = config.getStringOptional("mode").map(mode -> Mode.valueOf(mode.toUpperCase())).orElse(Mode.PERFORMANCE); ``` -------------------------------- ### Block value accessors Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/block.md Methods to set and get the stored value of a Block. For Section the stored value is Map>; for TerminatedBlock it is a plain Object. ```java public void setValue(T value) // line 191 public T getStoredValue() // line 292 ``` -------------------------------- ### Configure versioning with BasicVersioning Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Builds an UpdaterSettings with BasicVersioning that reads the version ID from the 'config-version' route. The version ID must be present in the defaults and cannot be changed later. ```java UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build(); ``` -------------------------------- ### YamlSerializer Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/serialization.md Interface for custom-object (de-)serialization. Installed via GeneralSettings.Builder.setSerializer(...). During loading every mapping node is offered to the serializer for deserialization, and during dumping supported objects are serialized back into maps. ```APIDOC ## YamlSerializer ### Description Interface for custom-object (de-)serialization. Installed via `GeneralSettings.Builder.setSerializer(...)`. During loading every mapping node is offered to the serializer for deserialization, and during dumping supported objects are serialized back into maps. ### Methods #### deserialize - **Signature:** `Object deserialize(@NotNull Map map)` - **Description:** Converts a raw map to an object. Return `null` if unrecognized or unable. #### serialize - **Signature:** ` Map serialize(@NotNull T object, @NotNull MapSupplier supplier)` - **Description:** Converts an object to a map using the supplier's map. Return `null` if unable. The object is guaranteed to be of a type in `getSupportedClasses()` or a subtype of one in `getSupportedParentClasses()`. #### getSupportedClasses - **Signature:** `Set> getSupportedClasses()` - **Description:** Returns the set of classes directly supported by this serializer. #### getSupportedParentClasses - **Signature:** `Set> getSupportedParentClasses()` - **Description:** Returns the set of parent classes whose subtypes are supported by this serializer. ``` -------------------------------- ### Key and route enumeration methods Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Methods for enumerating routes and keys relative to the current section. All return fresh instances from the configured GeneralSettings default collection suppliers, include entries from defaults when defaults are in use, and string routes use GeneralSettings.getRouteSeparator(). ```java public Set getRoutes(boolean deep) // line 514 public Set getRoutesAsStrings(boolean deep) // line 550 public Set getKeys() // line 576 public Map getRouteMappedValues(boolean deep) // line 622 public Map getStringRouteMappedValues(boolean deep) // line 659 public Map> getRouteMappedBlocks(boolean deep) // line 705 public Map> getStringRouteMappedBlocks(boolean deep) // line 742 ``` -------------------------------- ### Settings Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/types.md Marker interface implemented by all settings classes. Accepted as varargs by YamlDocument.create and setSettings. ```APIDOC ## Marker Interface: Settings ### Description Marker interface implemented by `GeneralSettings`, `LoaderSettings`, `DumperSettings`, `UpdaterSettings`. Accepted as varargs by `YamlDocument.create(...)`, the `protected` constructors and `setSettings(...)`. Custom settings must implement one of the four library classes — unknown instances are rejected with `IllegalArgumentException("Unknown settings object!")`. ### Interface ```java public interface Settings {} ``` ### Usage - Implemented by: `GeneralSettings`, `LoaderSettings`, `DumperSettings`, `UpdaterSettings` - Accepted by: `YamlDocument.create(...)`, protected constructors, `setSettings(...)` - Throws: `IllegalArgumentException` if an unknown settings object is passed. ``` -------------------------------- ### Custom TypeAdapter with StandardSerializer Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/serialization.md Example of creating a custom TypeAdapter for Vector3, registering it with the StandardSerializer, and using it with a YamlDocument. The adapter omits the type key, so the canonical class name is added automatically. The alias 'vec' is optional and must be registered. ```java // Custom type with the standard serializer StandardSerializer serializer = StandardSerializer.getDefault(); // GeneralSettings uses this by default TypeAdapter adapter = new TypeAdapter() { @Override public Map serialize(@NotNull Vector3 v) { Map map = new LinkedHashMap<>(); map.put("x", v.x); map.put("y", v.y); return map; // no "==" key → canonical class name is added automatically } @Override public Vector3 deserialize(@NotNull Map map) { Map m = toStringKeyedMap(map); return new Vector3((double) m.get("x"), (double) m.get("y"), 0); } }; serializer.register(Vector3.class, adapter); // canonical-name registration serializer.register("vec", Vector3.class); // optional alias // Wire into settings and use YamlDocument doc = YamlDocument.create(file, defaults, GeneralSettings.builder().setSerializer(serializer).build()); doc.set("spawn", new Vector3(10.5, 64, -20.5)); Vector3 spawn = doc.getAs("spawn", Vector3.class); // deserialized through the serializer ``` -------------------------------- ### LoaderSettings.isCreateFileIfAbsent() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Checks if the file should be created and saved when missing. ```APIDOC ## LoaderSettings.isCreateFileIfAbsent() ### Description Returns whether the file should be created and saved when missing. ### Method INSTANCE ### Endpoint LoaderSettings.isCreateFileIfAbsent() ### Parameters None ### Request Example ```java LoaderSettings settings = LoaderSettings.DEFAULT; boolean createFile = settings.isCreateFileIfAbsent(); ``` ### Response #### Success Response - **createFile** (boolean) - true if the file should be created, false otherwise. #### Response Example ```java true ``` ``` -------------------------------- ### Handle null from move() with fallback Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/section.md Shows how to use move and check its return value. If move returns null (because the source route did not exist), set a fallback value. This handles the absence case explicitly. ```java // Move and handle absence Block moved = config.move("old.path", "new.path"); if (moved == null) { config.set("new.path", "fallback"); } ``` -------------------------------- ### MultiKeyRoute method signatures Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/route.md Method signatures for MultiKeyRoute: constructor throws IllegalArgumentException on empty array and NullPointerException on null key; join, length, get, add, and parent behaviors are documented. equals/hashCode compare by key sequence, and a length-1 MultiKeyRoute equals a SingleKeyRoute with the same key. ```java public MultiKeyRoute(@NotNull Object... route) // line 36 — empty array → IllegalArgumentException; any null key → NullPointerException public String join(char separator) // line 47 public int length() // line 57 — backing array length public Object get(int i) // line 61 — direct array access (IndexOutOfBounds for bad index) public Route add(@NotNull Object key) // line 65 — array copy + append public Route parent() // line 72 — length 2 → Route.from(route[0]); else copy minus last ``` -------------------------------- ### Block constructors Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/block.md Constructors for the Block class. The first stores references to comments from the given SnakeYAML nodes. The second creates a comment-less block used by subclasses before init(Node, Node). The third copies all six comment collections from the previous block or starts empty if null. ```java public Block(@Nullable Node keyNode, @Nullable Node valueNode, @Nullable T value) // line 57 public Block(@Nullable T value) // line 70 public Block(@Nullable Block previous, @Nullable T value) // line 81 ``` -------------------------------- ### Manual update run with exception handling Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/updater.md Shows a manual update run using document.update(updaterSettings). Catches UnsupportedOperationException for downgrade attempts and IOException for save failures. ```java // Manual update run try { boolean changed = document.update(updaterSettings); } catch (UnsupportedOperationException downgrade) { log.warn("Refusing to downgrade the config: {}", downgrade.getMessage()); } catch (IOException e) { log.error("Could not save after update", e); } ``` -------------------------------- ### SingleKeyRoute method signatures Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/route.md Method signatures for SingleKeyRoute with documented behavior: constructor throws NullPointerException on null key; join returns key.toString(); length is 1; get throws ArrayIndexOutOfBoundsException unless i==0; parent throws IllegalArgumentException; add creates a new route from this key and the new key. ```java public SingleKeyRoute(@NotNull Object key) // line 34 — null → NullPointerException public String join(char separator) // line 40 — key.toString() public int length() // line 44 — 1 public Object get(int i) // line 48 — throws ArrayIndexOutOfBoundsException("Index " + i + " for single key route!") unless i == 0 public Route parent() // line 55 — IllegalArgumentException("Empty routes are not allowed!") public Route add(@NotNull Object key) // line 60 — Route.from(this.key, key) ``` -------------------------------- ### Create a YamlDocument with object key format Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Creates a YamlDocument configured to use KeyFormat.OBJECT via GeneralSettings, which is required when using Route objects. The create method also accepts default loader, dumper, and updater settings. ```java YamlDocument config = YamlDocument.create(new File("config.yml"), getResource("config.yml"), GeneralSettings.builder().setKeyFormat(KeyFormat.OBJECT).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.DEFAULT); ``` -------------------------------- ### Version.asID() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Returns the string representation of the version, e.g. "1.3". ```APIDOC ## asID() ### Description Returns the string representation of the version, e.g. "1.3". ### Method asID ### Signature `public String asID()` ### Returns - **String** - The version ID string. ``` -------------------------------- ### Create a YamlDocument with auto-update and versioning Source: https://github.com/dejvokep/boosted-yaml/blob/main/README.md Creates a YamlDocument with custom LoaderSettings that enables auto-update, and UpdaterSettings that uses BasicVersioning for the 'config-version' route. The document is automatically updated on creation and on each reload. ```java YamlDocument config = YamlDocument.create(new File("config.yml"), getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build()); ``` -------------------------------- ### Version class method signatures Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Lists the public methods of the Version class with their line numbers and brief behavior notes. compareTo throws ClassCastException if patterns differ; getCursor returns a value between 0 and Segment.length(); next() advances the least-significant cursor with carry-over; asID() returns the version string; copy() creates a shallow copy of cursors sharing the pattern. ```java public int compareTo(Version o) // line 58 — ClassCastException if patterns differ public int getCursor(int index) // line 89 — 0 <= cursor < Segment.length() public void next() // line 103 — advance least-significant cursor with carry-over public String asID() // line 145 — e.g. "1.3" public Version copy() // line 157 — shallow copy of cursors, shared pattern public Pattern getPattern() // line 166 public boolean equals(Object o) / public int hashCode() // lines 171 / 179 — pattern + cursors ``` -------------------------------- ### getFirstVersion() Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/dvs.md Returns the first version of the pattern, where all cursors are set to 0. ```APIDOC ## getFirstVersion() ### Description Returns the first version of the pattern, where all cursors are set to 0. ### Method Method ### Signature ```java public Version getFirstVersion() ``` ### Returns - **Version** - The first version with all cursors set to 0. ``` -------------------------------- ### UpdaterSettings.Builder Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/configuration.md Configuration builder for UpdaterSettings, allowing customization of update behavior such as auto-save, downgrading, merge rules, and versioning. ```APIDOC ## UpdaterSettings.Builder ### Description Builder class for configuring UpdaterSettings. Provides fluent setter methods for various update options. ### Methods #### setAutoSave - **Type**: `boolean` - **Default**: `true` - **Description**: Save the document after a successful update (skipped when nothing changed). #### setEnableDowngrading - **Type**: `boolean` - **Default**: `true` - **Description**: Allow updating against older defaults; `false` → `UnsupportedOperationException` on downgrade. #### setKeepAll - **Type**: `boolean` - **Default**: `false` - **Description**: Keep document-only blocks instead of deleting them during merge. #### setOptionSorting - **Type**: `OptionSorting` - **Default**: `SORT_BY_DEFAULTS` - **Description**: Merge ordering strategy. #### setMergeRules / setMergeRule - **Type**: `Map` - **Default**: `MAPPINGS → true`, others `false` - **Description**: Per-situation preserve-document flags. #### addIgnoredRoutes (+ variants) - **Type**: per version ID - **Default**: — (none) - **Description**: Routes excluded from merging at a target version ID. #### addRelocations (+ variants) - **Type**: per version ID - **Default**: — (none) - **Description**: from→to route relocations at a version ID. #### addMappers (+ variants) - **Type**: per version ID - **Default**: — (none) - **Description**: value transformations at a version ID. #### addCustomLogic (+ variants) - **Type**: per version ID - **Default**: — (none) - **Description**: custom `Consumer` logic at a version ID. #### setVersioning - **Type**: `Versioning` (or pattern/route shorthands) - **Default**: `null` - **Description**: Versioning strategy; required for versioned operations. ### Notes - All ignored routes/relocations/mappers/custom logic are keyed by **version ID string** (the `asID()` of each version in the upgrade range). - There are no runtime read-back setters — the settings are immutable after `build()`. ### See Also - [GeneralSettings](api-reference/generalsettings.md) - [LoaderSettings](api-reference/loadersettings.md) - [DumperSettings](api-reference/dumpersettings.md) - [UpdaterSettings](api-reference/updatersettings.md) - [YamlDocument](api-reference/yamldocument.md) ``` -------------------------------- ### LoaderSettings.builder(LoadSettingsBuilder builder) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Creates a Builder wrapping an existing SnakeYAML Engine LoadSettingsBuilder. Note: the engine builder is not cloned. ```APIDOC ## LoaderSettings.builder(LoadSettingsBuilder builder) ### Description Creates a Builder preset from an existing SnakeYAML Engine LoadSettingsBuilder. The engine builder is not cloned. ### Method STATIC ### Endpoint LoaderSettings.builder(LoadSettingsBuilder builder) ### Parameters #### Path Parameters - **builder** (LoadSettingsBuilder) - Required - The engine builder to wrap. ### Request Example ```java LoadSettingsBuilder engineBuilder = LoadSettingsBuilder.builder(); LoaderSettings.builder(engineBuilder) ``` ### Response #### Success Response - **builder** (Builder) - A new Builder instance. #### Response Example ```java LoaderSettings.builder(engineBuilder) ``` ``` -------------------------------- ### LoaderSettings.Builder.setCreateFileIfAbsent(boolean) Source: https://github.com/dejvokep/boosted-yaml/blob/main/_autodocs/api-reference/loadersettings.md Sets whether to create the file if absent. Default is true. ```APIDOC ## LoaderSettings.Builder.setCreateFileIfAbsent(boolean) ### Description Sets whether the file should be created and saved when missing. Default is true. ### Method INSTANCE ### Endpoint LoaderSettings.Builder.setCreateFileIfAbsent(boolean createFileIfAbsent) ### Parameters #### Path Parameters - **createFileIfAbsent** (boolean) - Required - true to create the file, false otherwise. ### Request Example ```java LoaderSettings.builder().setCreateFileIfAbsent(false) ``` ### Response #### Success Response - **builder** (Builder) - This builder for chaining. #### Response Example ```java LoaderSettings.builder().setCreateFileIfAbsent(false) ``` ```