Class NameAdapter
- All Implemented Interfaces:
Accessor
Accessor for extracting
name information from objects that expose a getName() method.
This adapter wraps supported objects into the Nameable interface, which unifies
access to name-like properties through a standard Nameable.getName() accessor.
The resulting Nameable can then be used in the message pipeline to perform macro substitution
for placeholders such as {OBJECT.NAME}.
Supported types include:
CommandSenderOfflinePlayerPlayerProfileWorldServerPlugin
If the provided object is already an instance of Nameable, it is returned directly.
Otherwise, the adapter attempts to map a known getName() source into a Nameable
lambda reference. If no match is found, an empty Optional is returned.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.winterhavenmc.library.messagebuilder.core.ports.pipeline.accessors.Accessor
Accessor.BuiltIn -
Field Summary
Fields inherited from interface com.winterhavenmc.library.messagebuilder.core.ports.pipeline.accessors.Accessor
UNKNOWN_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionNameAdapter(AccessorCtx ctx) Constructs a newDisplayNameAdapterwith the given context container. -
Method Summary
-
Constructor Details
-
NameAdapter
Constructs a newDisplayNameAdapterwith the given context container.- Parameters:
ctx- the adapter context providing services such as world name resolution
-
-
Method Details
-
adapt
Attempts to adapt the given object to aNameable, if it exposes a name field.Returns a
Optionalcontaining aNameablewrapper if the object is a known type that provides agetName()method, either directly or indirectly. Returns an emptyOptionalif the object does not expose a supported name source.
-