Class RemoteConfigEntries

java.lang.Object
com.ultikits.ultitools.utils.RemoteConfigEntries

final class RemoteConfigEntries extends Object
The typed entry model of one module configuration file, and the per-key check of a panel change.

An entry is one @ConfigEntry field whose declared type the frozen protocol can carry: a String (string), an int/long/short/byte and their boxed forms (integer), a float/double and their boxed forms (number), a boolean (boolean), a List<String> (string_list) or an enum (enum, whose constant names are the allowed options). Every other declared type - a map, an object, a Bukkit value, a list of anything but strings - is not editable through the panel and is not listed, so a panel change can only ever name a value the contract has a shape for.

Values come from the file's raw bytes through ConfigDocument, never from the module's in-memory state: the panel reads what the operator's file holds, and the version it then sends back is the hash of exactly those bytes. An entry whose value cannot be carried inside the contract's own bounds (a text longer than 8192 characters, a list longer than 500 items, an integer outside the safe integer range) is omitted rather than truncated, because a truncated value is one the panel would write back.

Every frame the builder produces therefore stays inside the vendored config.entries.result schema: bounds are applied while the entry is built, and an entry that cannot satisfy them is dropped, never emitted in a shape the schema rejects.

Since:
6.3.1
  • Field Details

  • Constructor Details

    • RemoteConfigEntries

      private RemoteConfigEntries()
  • Method Details

    • kindOf

      static RemoteConfigEntries.Kind kindOf(Field field)
      Maps one field's declared type to the contract entry type.
      Parameters:
      field - the @ConfigEntry field
      Returns:
      the kind, or null when the type is not editable through the panel
    • stringList

      private static boolean stringList(Field field)
    • keyOf

      static String keyOf(Field field)
      The dotted key of one @ConfigEntry field: its path() split at every dot, or the field name when no path is declared - the same rule the entity applies when it binds the field.
      Parameters:
      field - the annotated field
      Returns:
      the dotted key
    • usableKey

      static boolean usableKey(String key)
      Parameters:
      key - a dotted key @return whether the contract's key pattern accepts it
    • describe

      static List<RemoteConfigEntries.Entry> describe(AbstractConfigEntity entity, ConfigDocument document)
      Builds the editable entries of one file as it is on disk.
      Parameters:
      entity - the module's config entity that registered the file
      document - the document loaded from the file's current bytes
      Returns:
      the entries the panel may show, in declaration order, bounded by the contract
    • label

      private static String label(String key)
    • commentOf

      private static String commentOf(com.google.gson.JsonObject comments, String key)
    • options

      private static List<String> options(Field field)
    • valueOf

      private static com.google.gson.JsonElement valueOf(Object plain, RemoteConfigEntries.Kind kind, List<String> options)
      Converts one plain value read from the file to the entry's wire value.
      Parameters:
      plain - the plain value, or null when the file does not hold the key
      kind - the entry kind
      options - the enum constant names, empty for every other kind
      Returns:
      the wire value, or null when the value cannot be carried inside the contract's bounds
    • integral

      private static Long integral(Object plain)
    • number

      private static Double number(Object plain)
    • list

      private static com.google.gson.JsonElement list(Object plain)
    • constraints

      private static com.google.gson.JsonObject constraints(Field field, RemoteConfigEntries.Kind kind, List<String> options)
    • usableNumberBound

      private static boolean usableNumberBound(double bound)
      The default @Range bound is the whole double range, which means "no bound".
    • bound

      private static Long bound(double value, boolean min)
    • check

      static String check(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry)
      Checks one panel change against its entry: the JSON value's shape for that entry type and, for a bounded number, the declared range. Constraints the entity declares for a whole field (a size, a pattern, the module's own converter) are checked by the entity itself, not here.
      Parameters:
      value - the JSON value the panel sent
      entry - the entry the change names, or null when the key is not an editable entry
      Returns:
      null when the value may be written, otherwise a short reason for the key's result row
    • checkInteger

      private static String checkInteger(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry)
    • checkNumber

      private static String checkNumber(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry)
    • withinRange

      private static boolean withinRange(com.google.gson.JsonObject constraints, double number)
    • rangeMessage

      private static String rangeMessage(com.google.gson.JsonObject constraints)
    • checkList

      private static String checkList(com.google.gson.JsonElement value)
    • checkEnum

      private static String checkEnum(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry)
    • plain

      static Object plain(com.google.gson.JsonElement value, RemoteConfigEntries.Kind kind)
      Converts a checked JSON value to the plain value the configuration document stores.
      Parameters:
      value - the JSON value
      kind - the entry kind
      Returns:
      the plain value
    • find

      Finds the entry a dotted key names.
      Parameters:
      entries - the described entries
      key - the change's dotted key
      Returns:
      the entry, or null when that key is not an editable entry of this file