Interface ConfigMigration

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ConfigMigration
Upgrades a config file's contents by one version, before the values are read. The file's version is kept in its "$version" key; a config built with ConfigBuilder.version(int) runs every migration from the file's version up to its own, in order, then rewrites the file.
builder.version(2).migration(1, root -> {
    // "renderDistance" moved into the "rendering" group
    JsonObject rendering = root.getAsJsonObject("rendering");
    rendering.add("distance", root.remove("renderDistance"));
});
Simple renames don't need a migration: see aliases on the entry builders.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    migrate(com.google.gson.JsonObject root)
     
  • Method Details

    • migrate

      void migrate(com.google.gson.JsonObject root)
      Parameters:
      root - the file's contents as nested objects, whatever its format; change it in place