Class MacroFieldAccessor
java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.pipeline.accessors.MacroFieldAccessor
- All Implemented Interfaces:
FieldAccessor
Default implementation of the
FieldAccessor interface that delegates
field extraction to the appropriate functional interface based on the adapter type.
The MacroFieldAccessor 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 ValidMacroKey.
This implementation supports all built-in Accessor 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 newMacroFieldAccessorwith the provided context container. -
Method Summary
Modifier and TypeMethodDescription<T> MacroStringMapextract(ValidMacroKey baseKey, Accessor accessor, T adapted) Extracts macro string values from the adapted object using the accessor's corresponding interface, such asNameableorLocatable.
-
Constructor Details
-
MacroFieldAccessor
Constructs a newMacroFieldAccessorwith 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 accessor's corresponding interface, such asNameableorLocatable.If the accessor 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 accessor/object combination, an empty
MacroStringMapis returned.- Specified by:
extractin interfaceFieldAccessor- Type Parameters:
T- the type of the adapted object- Parameters:
baseKey- the baseValidMacroKeyrepresenting the placeholder prefixaccessor- the accessor that was used to adapt the original objectadapted- the adapted object implementing one of the field interfaces- Returns:
- a
MacroStringMapcontaining extracted macro values
-