Record Class MenuId<C>

java.lang.Object
java.lang.Record
de.Keyle.MyPet.api.gui.MenuId<C>
Type Parameters:
C - the context type this menu is opened with
Record Components:
id - the JSON file basename identifying the menu
contextType - the context class, used to type-check callers

public record MenuId<C>(String id, Class<C> contextType) extends Record
Typed identity of a registered menu. `id` is the JSON file basename (e.g. "pet-selection"); `contextType` lets GuiService.openMenu(org.bukkit.entity.Player, de.Keyle.MyPet.api.gui.MenuId<C>, C) type-check the caller's context.
  • Constructor Details

    • MenuId

      public MenuId(String id, Class<C> contextType)
      Creates an instance of a MenuId record class.
      Parameters:
      id - the value for the id record component
      contextType - the value for the contextType record component
  • Method Details

    • of

      public static <C> MenuId<C> of(String id, Class<C> type)
      Creates a menu id.
      Type Parameters:
      C - the context type this menu is opened with
      Parameters:
      id - the JSON file basename identifying the menu
      type - the context class, used to type-check callers
      Returns:
      the new menu id
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • contextType

      public Class<C> contextType()
      Returns the value of the contextType record component.
      Returns:
      the value of the contextType record component