-
Notifications
You must be signed in to change notification settings - Fork 0
API Cheat Sheet
Petrus Pradella edited this page Jun 27, 2026
·
6 revisions
A one-page reference. See the linked pages for detail.
Open / lifecycle — Lifecycle, Reload & Watching
Config cfg = Config.open(path, codec); // ABSENT / EMPTY / PARSE_FAILED_BACKED_UP / OK
cfg.save(); cfg.saveIfDirty(); cfg.saveAsync();
cfg.reload(); // OK / ABSENT / PARSE_FAILED_KEPT
cfg.onReload(runnable).withAutoReload(Duration.ofSeconds(2)); cfg.stopAutoReload();
cfg.close(); // AutoCloseable
cfg.lastLoadStatus(); cfg.isDivergedFromDisk(); cfg.getLastModified(); cfg.hasBeenModified();Set / remove — The Dynamic API
cfg.setValue(path, value); // null value deletes; auto-vivifies objects
cfg.setValue(path, value, comment);
cfg.removeValue(path); cfg.clear(path); // booleangetString getInt getLong getDouble getBoolean getStringList getList getUUID // + (path, default) forms
getValue(path) // unwrapped scalar / node
getNode(path) // raw JsonNode or nullcfg.contains(path);
cfg.getKeys(); cfg.getKeys(path); cfg.getKeys(path, true /*deep*/);
cfg.getConfigSection(path); // always a view
cfg.getConfigurationSection(path); // null if absent / not an object
cfg.getRoot(); // live ObjectNode escape hatchDefaults & comments — Default Values & Comments
cfg.getOrSetDefaultValue(path, def);
cfg.getOrSetDefaultValue(path, def, comment); // seeds comment if absent
cfg.setComment(path, text); // authoritative (CommentType.BLOCK default)
cfg.setDefaultComment(path, text); // set-if-absent
cfg.getComment(path); cfg.getComment(path, CommentType.SIDE);
cfg.migrateKey(oldPath, newPath);Binding — Entity Binding
T pojo = cfg.loadAs(Type.class, codec); // bind + @PostInject
EntityBinder<T> b = cfg.bind(Type.class, codec, opts); // b.bind(); b.lastLoadIssues();
cfg.mergeFrom(pojo, codec); // merge into the tree
BindOptions.defaults()
.withCoercion(BindOptions.Coercion.STRICT) // or LENIENT (default)
.withObsoletePolicy(BindOptions.ObsoletePolicy.REMOVE); // or PRESERVE (default)
@Id collections — @Id Collections
cfg.writeIdCollection(path, collection, codec);
List<T> back = cfg.readIdCollection(path, Type.class, codec);
cfg.lastIdCollectionIssues();Annotations — Annotations
@Key(value, transformCase) @Comment(value, mode) @Section("a.b") @Id @PostInject
KeyTransformCase.{NONE, KEBAB_CASE, SNAKE_CASE, CAMEL_CASE, UPPER_CAMEL_CASE}
CommentMode.{OVERRIDE, SET_IF_ABSENT}
Codecs — Codecs & Formats
new YamlCodec() // LOSSLESS yml, yaml
new JsonCodec() // NONE json
new TomlCodec() // LOSSLESS toml (no null)
new JsoncCodec() // LOSSY jsonc
CodecRegistry.defaults().forFile("a.toml"); // resolve by extensionEveryConfig · br.com.finalcraft:EveryConfig · One config API, every format, comments included · made by Petrus Pradella
Getting Started
Core Concepts
Typed Binding
Operations
Reference
Contributing