Record Class ConfigReference

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.config.ConfigReference
Record Components:
target - The primary ConfigDescription target to evaluate first.
fallback - An optional secondary ConfigDescription used when the primary target's mod is not loaded.

public record ConfigReference(johnsmith.configoverhauled.api.data.ConfigDescription target, Optional<johnsmith.configoverhauled.api.data.ConfigDescription> fallback) extends Record
Represents a reference to a dynamic configuration property, supporting both direct targeting and conditional mod-dependent fallback resolution ("try_config" / "else_config").

During resolution, if a fallback is defined and the primary target mod is not loaded according to ModLoadEvaluator, the reference transparently falls back to the secondary target. If the resulting target's ConfigManager is absent, the reference is routed through OrphanHandler for adoption.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<ConfigReference>
    Primary codec capable of serializing and deserializing either a direct ConfigDescription object or a conditional "try_config" / "else_config" structure.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConfigReference(johnsmith.configoverhauled.api.data.ConfigDescription target, Optional<johnsmith.configoverhauled.api.data.ConfigDescription> fallback)
    Creates an instance of a ConfigReference record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Optional<johnsmith.configoverhauled.api.data.ConfigDescription>
    Returns the value of the fallback record component.
    final int
    Returns a hash code value for this object.
    johnsmith.configoverhauled.api.data.ConfigDescription
    Resolves the active ConfigDescription for the current runtime environment.
    johnsmith.configoverhauled.api.data.ConfigDescription
    Returns the value of the target 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
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<ConfigReference> CODEC
      Primary codec capable of serializing and deserializing either a direct ConfigDescription object or a conditional "try_config" / "else_config" structure.
  • Constructor Details

    • ConfigReference

      public ConfigReference(johnsmith.configoverhauled.api.data.ConfigDescription target, Optional<johnsmith.configoverhauled.api.data.ConfigDescription> fallback)
      Creates an instance of a ConfigReference record class.
      Parameters:
      target - the value for the target record component
      fallback - the value for the fallback record component
  • Method Details

    • resolve

      public johnsmith.configoverhauled.api.data.ConfigDescription resolve()
      Resolves the active ConfigDescription for the current runtime environment.

      Evaluates fallback if present and the primary target's mod is not loaded. If no ConfigManager is registered for the active target's namespace, the description is passed to OrphanHandler.adopt(ConfigDescription).

      Returns:
      The resolved, valid ConfigDescription.
    • 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.
    • target

      public johnsmith.configoverhauled.api.data.ConfigDescription target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component
    • fallback

      public Optional<johnsmith.configoverhauled.api.data.ConfigDescription> fallback()
      Returns the value of the fallback record component.
      Returns:
      the value of the fallback record component