Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Nameable
A functional interface representing an object with a name field, commonly used in Adapter implementations that expose a getName() method.

This interface includes utility methods for validating, formatting, and extracting the name field as part of macro resolution in the message pipeline.

It is designed for use with Adapter classes to wrap Bukkit objects or domain models that provide a display name or identifier suitable for macro replacement.

See Also:
  • Field Details

    • VALID_NAME

      static final Predicate<String> VALID_NAME
      A predicate that determines whether a given name string is valid.

      A name is considered valid if it is non-null and not blank (i.e., not composed entirely of whitespace).

      This predicate is primarily used by formatName(String) to decide whether a name should be included in macro substitution output.

  • Method Details

    • getName

      String getName()
      Returns the name associated with the implementing object.
      Returns:
      the name of the object, typically used for macro substitution
    • extractName

      default MacroStringMap extractName(MacroKey baseKey, AdapterContextContainer ctx)
      Extracts the name field into a MacroStringMap, using the provided base key to construct a dot-notated macro key (e.g., OBJECT.NAME).

      The name is formatted and validated before being inserted into the map. If the base key cannot be extended (e.g., due to a parse error), an empty map is returned.

      Parameters:
      baseKey - the top-level macro key to use as the namespace for the field
      ctx - an unused adapter context container (reserved for future use)
      Returns:
      a map containing the extracted name value, or an empty map if the name is invalid
    • formatName

      static Optional<String> formatName(String name)
      Formats the given name string, returning it as an Optional if valid. Names are considered valid if they are non-null and not blank.
      Parameters:
      name - the raw name string to validate and format
      Returns:
      an optional containing the formatted name, or empty if invalid