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 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
ValidConstantRecord
– A successfully parsed constant entryInvalidConstantRecord
– A fallback constant representing a missing or invalid value
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 Summary
Static MethodsModifier and TypeMethodDescriptionstatic InvalidConstantRecord
Returns anInvalidConstantRecord
representing a missing or null constant entry.static ConstantRecord
Factory method that attempts to create aConstantRecord
from the given value.Methods inherited from interface com.winterhavenmc.library.messagebuilder.model.language.SectionRecord
key
-
Method Details
-
from
Factory method that attempts to create aConstantRecord
from the given value.If the value is
null
, returns anInvalidConstantRecord
. Otherwise, attempts to construct aValidConstantRecord
via validation.- Parameters:
constantKey
- the unique key identifying the constantconstantEntry
- the raw object value from the configuration- Returns:
- a valid or invalid
ConstantRecord
, depending on the input
-
empty
Returns anInvalidConstantRecord
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
-