All Superinterfaces:
SectionRecord
All Known Implementing Classes:
InvalidConstantRecord, ValidConstantRecord

public sealed interface ConstantRecord extends SectionRecord permits ValidConstantRecord, InvalidConstantRecord
A sealed interface representing a key–value pair loaded from the CONSTANTS section of a language YAML file.

Constants are globally accessible static values — such as strings, numbers, or booleans — that can be referenced in messages via macros. For example, a constant named SERVER_NAME might contain the string "Winterhaven".

Implementations

Instances are created via from(RecordKey, Object) to ensure proper validation. This interface extends SectionRecord, and is safe to pass through the library once constructed.

See Also:
  • Method Details

    • from

      static ConstantRecord from(RecordKey constantKey, Object constantEntry)
      Factory method that attempts to create a ConstantRecord from the given value.

      If the value is null, returns an InvalidConstantRecord. Otherwise, attempts to construct a ValidConstantRecord via validation.

      Parameters:
      constantKey - the unique key identifying the constant
      constantEntry - the raw object value from the configuration
      Returns:
      a valid or invalid ConstantRecord, depending on the input
    • empty

      static InvalidConstantRecord empty(RecordKey constantKey)
      Returns an InvalidConstantRecord representing a missing or null constant entry.
      Parameters:
      constantKey - the key associated with the unresolved constant
      Returns:
      a fallback ConstantRecord with a standard failure reason