java.lang.Object
com.winterhavenmc.library.messagebuilder.keys.AbstractKey
com.winterhavenmc.library.messagebuilder.keys.MacroKey
All Implemented Interfaces:
StandardKey

public final class MacroKey extends AbstractKey implements StandardKey
A type that represents a validated key for a macro. This type guarantees a valid key that has been validated upon creation. The static factory methods return an Optional of the RecordKey, or an empty Optional if the parameter was invalid, as determined by regex pattern and Predicate.
  • Method Details

    • of

      public static Optional<MacroKey> of(String key)
      Static factory method for instantiating a record key from a string
      Parameters:
      key - a String to be used in the creation of a record key
      Returns:
      an Optional RecordKey, or an empty Optional if the key parameter is null or invalid
    • of

      public static <E extends Enum<E>> Optional<MacroKey> of(E key)
      Static factory method for instantiating a record key from an enum constant
      Type Parameters:
      E - an enum constant
      Parameters:
      key - an enum constant whose name is used to create a record key
      Returns:
      an Optional RecordKey, or an empty Optional if the key parameter is null or invalid
    • append

      public <E extends Enum<E>> Optional<MacroKey> append(E subKey)
      Create a new key by suffixing a dot-separated subkey to this existing key
      Type Parameters:
      E - an enum constant
      Parameters:
      subKey - an enu constant whose name() is to be used for the appended subkey
      Returns:
      a new key with the subkey appended, or an empty Optional if the string was not a valid key
    • append

      public Optional<MacroKey> append(String subKey)
      Create a new key by suffixing a dot-separated subkey to this existing key
      Parameters:
      subKey - a string to be used for the appended subkey
      Returns:
      a new key with the subkey appended, or an empty Optional if the string was not a valid key
    • getBase

      public MacroKey getBase()
    • asPlaceholder

      public String asPlaceholder()