Class NameAdapter
- All Implemented Interfaces:
Adapter
Adapter
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:
CommandSender
OfflinePlayer
PlayerProfile
World
Server
Plugin
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.pipeline.adapters.Adapter
Adapter.BuiltIn
-
Field Summary
Fields inherited from interface com.winterhavenmc.library.messagebuilder.pipeline.adapters.Adapter
UNKNOWN_VALUE
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
NameAdapter
public NameAdapter()
-
-
Method Details
-
adapt
Attempts to adapt the given object to aNameable
, if it exposes a name field.Returns a
Optional
containing aNameable
wrapper if the object is a known type that provides agetName()
method, either directly or indirectly. Returns an emptyOptional
if the object does not expose a supported name source.
-