Class AtomicResolver
java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.resolvers.AtomicResolver
- All Implemented Interfaces:
Resolver
A
Resolver
implementation that handles simple or atomic values,
converting them into formatted strings mapped directly to the base MacroKey
.
The AtomicResolver
is typically used as the final step in a resolution chain,
after more complex resolvers (such as CompositeResolver
) have had a chance
to handle structured objects. It processes values such as Boolean
, String
, Number
,
Duration
, and other primitive or directly representable types.
Formatting is applied for supported types:
Number
values are formatted using aLocaleNumberFormatter
Duration
andBoundedDuration
values are formatted using aDurationFormatter
- All other values fall back to
toString()
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAtomicResolver
(FormatterContainer formatterContainer) Constructs anAtomicResolver
using the provided formatter container. -
Method Summary
Modifier and TypeMethodDescriptionresolve
(MacroKey macroKey, MacroObjectMap macroObjectMap) Resolves a single value mapped to the providedMacroKey
into a string representation, if the object exists and can be formatted.
-
Constructor Details
-
AtomicResolver
Constructs anAtomicResolver
using the provided formatter container.- Parameters:
formatterContainer
- a container providing formatters for durations and numbers- Throws:
IllegalArgumentException
- if the formatter container isnull
-
-
Method Details
-
resolve
Resolves a single value mapped to the providedMacroKey
into a string representation, if the object exists and can be formatted.Only one entry is produced per resolution: a single mapping from the
macroKey
to the formatted string value.- Specified by:
resolve
in interfaceResolver
- Parameters:
macroKey
- the key used to retrieve the value from the macro object mapmacroObjectMap
- the object map containing macro values to be resolved- Returns:
- a
MacroStringMap
containing at most one resolved key-value pair
-