Class FieldExtractor
java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.extractor.FieldExtractor
- All Implemented Interfaces:
Extractor
Default implementation of the
Extractor
interface that delegates
field extraction to the appropriate functional interface based on the adapter type.
The FieldExtractor
is responsible for mapping adapted objects (e.g., Nameable
,
Locatable
, Quantifiable
, etc.) to their extracted macro string values.
These values are inserted into a MacroStringMap
, keyed by the supplied MacroKey
.
This implementation supports all built-in Adapter
types and ensures
that the correct extraction method is called based on both the adapter class
and the runtime type of the adapted object.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newFieldExtractor
with the provided context container. -
Method Summary
Modifier and TypeMethodDescription<T> MacroStringMap
Extracts macro string values from the adapted object using the adapter's corresponding interface, such asNameable
orLocatable
.
-
Constructor Details
-
FieldExtractor
Constructs a newFieldExtractor
with the provided context container.- Parameters:
ctx
- the context container holding formatter and configuration dependencies
-
-
Method Details
-
extract
Extracts macro string values from the adapted object using the adapter's corresponding interface, such asNameable
orLocatable
.If the adapter is recognized and the adapted object is an instance of the expected functional interface, the appropriate extractor method is invoked.
If no valid match is found for the adapter/object combination, an empty
MacroStringMap
is returned.- Specified by:
extract
in interfaceExtractor
- Type Parameters:
T
- the type of the adapted object- Parameters:
baseKey
- the baseMacroKey
representing the placeholder prefixadapter
- the adapter that was used to adapt the original objectadapted
- the adapted object implementing one of the field interfaces- Returns:
- a
MacroStringMap
containing extracted macro values
-