Record Class DataTransformerRegistry.FieldWrapperTransformer

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.registry.DataTransformerRegistry.FieldWrapperTransformer
Record Components:
key - The top-level JSON property key on the enchantment object.
propertyName - The generated configuration property name.
All Implemented Interfaces:
DataTransformerRegistry.Transformer
Enclosing class:
DataTransformerRegistry

public static record DataTransformerRegistry.FieldWrapperTransformer(String key, String propertyName) extends Record implements DataTransformerRegistry.Transformer
Standard DataTransformerRegistry.Transformer implementation for wrapping and unwrapping top-level enchantment definition fields into {"config": ..., "fallback": ...} objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a FieldWrapperTransformer record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyExport(com.google.gson.JsonObject root)
    Mutates the enchantment JSON tree during the export phase, unwrapping dynamic configuration structures back into their static fallback representations.
    void
    applyImport(com.google.gson.JsonObject root, String targetNamespace, String enchantmentName)
    Mutates the enchantment JSON tree during the import phase, wrapping static values into dynamic configuration structures bound to targetNamespace.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    key()
    Returns the value of the key record component.
    Returns the value of the propertyName record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FieldWrapperTransformer

      public FieldWrapperTransformer(String key, String propertyName)
      Creates an instance of a FieldWrapperTransformer record class.
      Parameters:
      key - the value for the key record component
      propertyName - the value for the propertyName record component
  • Method Details

    • applyImport

      public void applyImport(com.google.gson.JsonObject root, String targetNamespace, String enchantmentName)
      Description copied from interface: DataTransformerRegistry.Transformer
      Mutates the enchantment JSON tree during the import phase, wrapping static values into dynamic configuration structures bound to targetNamespace.
      Specified by:
      applyImport in interface DataTransformerRegistry.Transformer
      Parameters:
      root - The root enchantment JsonObject being mutated.
      targetNamespace - The mod namespace assigned to the generated configuration properties.
      enchantmentName - The path identifier of the target enchantment (used as the config group name).
    • applyExport

      public void applyExport(com.google.gson.JsonObject root)
      Description copied from interface: DataTransformerRegistry.Transformer
      Mutates the enchantment JSON tree during the export phase, unwrapping dynamic configuration structures back into their static fallback representations.
      Specified by:
      applyExport in interface DataTransformerRegistry.Transformer
      Parameters:
      root - The root enchantment JsonObject being mutated.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • propertyName

      public String propertyName()
      Returns the value of the propertyName record component.
      Returns:
      the value of the propertyName record component