Class MessageRetriever
java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.retriever.MessageRetriever
- All Implemented Interfaces:
Retriever
Default implementation of the
Retriever
interface that retrieves
a MessageRecord
using a QueryHandler
.
This class ensures safety and consistency by always returning a non-null record. If the underlying query handler fails to provide a valid message, a fallback empty record is returned instead.
This class is typically used as the entry point in a
MessagePipeline
.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMessageRetriever
(QueryHandler<MessageRecord> queryHandler) Constructs aMessageRetriever
using the specified query handler. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves aMessageRecord
for the given key using the underlyingQueryHandler
.
-
Constructor Details
-
MessageRetriever
Constructs aMessageRetriever
using the specified query handler.- Parameters:
queryHandler
- a handler responsible for resolving message records from a configuration source
-
-
Method Details
-
getRecord
Retrieves aMessageRecord
for the given key using the underlyingQueryHandler
.If the result is not an instance of
ValidMessageRecord
, this method returns an empty record as a safe fallback.
-