Interface ConstantRecord
- All Superinterfaces:
SectionRecord
- All Known Implementing Classes:
InvalidConstantRecord,ValidConstantRecord
public sealed interface ConstantRecord
extends SectionRecord
permits ValidConstantRecord, InvalidConstantRecord
A sealed interface representing a string–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
ValidConstantRecord– A successfully parsed constant entryInvalidConstantRecord– A fallback constant representing a missing or invalid value
Instances are created via of(ValidConstantKey, Object) to ensure proper
validation. This interface extends SectionRecord, and is safe to pass
through the library once constructed.
- See Also:
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic InvalidConstantRecordempty(RecordKey constantKey, InvalidRecordReason reason) Returns anInvalidConstantRecordrepresenting a missing or null constant entry.static ConstantRecordof(ValidConstantKey constantKey, Object constantEntry) Factory method that attempts to create aConstantRecordfrom the given value.Methods inherited from interface com.winterhavenmc.library.messagebuilder.models.language.SectionRecord
key
-
Method Details
-
of
Factory method that attempts to create aConstantRecordfrom the given value.If the value is
null, returns anInvalidConstantRecord. Otherwise, attempts to construct aValidConstantRecordvia validation.- Parameters:
constantKey- the unique string identifying the constantconstantEntry- the raw object value from the configuration- Returns:
- a valid or invalid
ConstantRecord, depending on the input
-
empty
Returns anInvalidConstantRecordrepresenting a missing or null constant entry.- Parameters:
constantKey- the string associated with the unresolved constant- Returns:
- a fallback
ConstantRecordwith a standard failure reason
-