Class DefaultConfigParser

java.lang.Object
com.ultikits.ultitools.interfaces.impl.pasers.ConfigParser<Object>
com.ultikits.ultitools.interfaces.impl.pasers.DefaultConfigParser
All Implemented Interfaces:
ObjectConfigSerializer<Object>, Parser<Object>

public class DefaultConfigParser extends ConfigParser<Object>
  • Constructor Details

    • DefaultConfigParser

      public DefaultConfigParser()
  • Method Details

    • parse

      public Object parse(Object object)
      Description copied from interface: Parser
      Parses a raw object into the target type.
      Parameters:
      object - the raw object to parse (typically from configuration)
      Returns:
      the parsed object of type T
    • serializeToMemorySection

      public org.bukkit.configuration.MemorySection serializeToMemorySection(Object object)
      Serializes object into a MemorySection.

      Map and Collection values are walked by their own entries/elements rather than reflected on: a Map/Collection instance's own fields are a JDK implementation detail (e.g. LinkedHashMap's table/head/ tail/modCount), and reflecting on them is wrong even where setAccessible succeeds - it would persist the container's internal bookkeeping instead of its actual contents. On Java 16+ it additionally throws InaccessibleObjectException the first time it tries to open a private java.util field (e.g. LinkedHashMap#serialVersionUID), because java.base does not open java.util to an unnamed module.

      Everything else falls back to the pre-existing reflective walk of the object's own fields, skipping static, transient, and synthetic fields: static fields (like the JDK's own serialVersionUID) are never per-instance state, transient fields are the field author's own "do not persist this" signal, and synthetic fields are compiler-generated bookkeeping (e.g. outer-class references) with no meaningful config representation.

      Parameters:
      object - the object to serialize
      Returns:
      the populated MemorySection