Record Class ConfigReference
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.config.ConfigReference
- Record Components:
target- The primaryConfigDescriptiontarget to evaluate first.fallback- An optional secondaryConfigDescriptionused 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
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ConfigReference> Primary codec capable of serializing and deserializing either a directConfigDescriptionobject or a conditional"try_config"/"else_config"structure. -
Constructor Summary
ConstructorsConstructorDescriptionConfigReference(johnsmith.configoverhauled.api.data.ConfigDescription target, Optional<johnsmith.configoverhauled.api.data.ConfigDescription> fallback) Creates an instance of aConfigReferencerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Optional<johnsmith.configoverhauled.api.data.ConfigDescription> fallback()Returns the value of thefallbackrecord component.final inthashCode()Returns a hash code value for this object.johnsmith.configoverhauled.api.data.ConfigDescriptionresolve()Resolves the activeConfigDescriptionfor the current runtime environment.johnsmith.configoverhauled.api.data.ConfigDescriptiontarget()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
Primary codec capable of serializing and deserializing either a directConfigDescriptionobject 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 aConfigReferencerecord class.
-
-
Method Details
-
resolve
public johnsmith.configoverhauled.api.data.ConfigDescription resolve()Resolves the activeConfigDescriptionfor the current runtime environment.Evaluates
fallbackif present and the primary target's mod is not loaded. If noConfigManageris registered for the active target's namespace, the description is passed toOrphanHandler.adopt(ConfigDescription).- Returns:
- The resolved, valid
ConfigDescription.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
target
public johnsmith.configoverhauled.api.data.ConfigDescription target()Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
fallback
Returns the value of thefallbackrecord component.- Returns:
- the value of the
fallbackrecord component
-