Record Class CustomId

java.lang.Object
java.lang.Record
com.github.kaktushose.jda.commands.definitions.interactions.CustomId
Record Components:
runtimeId - the id of the Runtime this custom id is bound to or the literal independent.
definitionId - the Definition.definitionId()

public record CustomId(@NotNull String runtimeId, @NotNull String definitionId) extends Record
Representation of a custom id used in modals, buttons or select menus.
Implementation Note:
the custom id has the following format: jdac.runtimeId.definitionId
  • Field Details

    • BOUND_CUSTOM_ID_REGEX

      public static final String BOUND_CUSTOM_ID_REGEX
      See Also:
    • INDEPENDENT_CUSTOM_ID_REGEX

      public static final String INDEPENDENT_CUSTOM_ID_REGEX
  • Constructor Details

    • CustomId

      public CustomId(@NotNull @NotNull String runtimeId, @NotNull @NotNull String definitionId)
      Creates an instance of a CustomId record class.
      Parameters:
      runtimeId - the value for the runtimeId record component
      definitionId - the value for the definitionId record component
  • Method Details

    • fromEvent

      @NotNull public static @NotNull CustomId fromEvent(@NotNull @NotNull GenericComponentInteractionCreateEvent event)
      Constructs a new CustomId from the given GenericInteractionCreateEvent.
      Parameters:
      event - the GenericInteractionCreateEvent
      Returns:
      the CustomId
    • fromEvent

      @NotNull public static @NotNull CustomId fromEvent(@NotNull @NotNull ModalInteractionEvent event)
      Constructs a new CustomId from the given ModalInteractionEvent.
      Parameters:
      event - the ModalInteractionEvent
      Returns:
      the CustomId
    • independent

      @NotNull public static @NotNull CustomId independent(@NotNull @NotNull String definitionId)
      Constructs a new runtime-independent CustomId from the given definition id.
      Parameters:
      definitionId - the definition id to construct the CustomId from
      Returns:
      a new runtime-independent CustomId
    • isInvalid

      public static boolean isInvalid(@NotNull @NotNull String customId)
      Checks if the passed custom id doesn't conform to the defined format of jda-commands.
      Returns:
      true if the passed custom id doesn't conform to the jda-commands format
    • id

      @NotNull public @NotNull String id()
      The String representation of this custom id.
    • runtimeId

      @NotNull public @NotNull String runtimeId()
      Gets the runtime id of this custom id.
      Returns:
      the runtime id
      Throws:
      IllegalStateException - if this custom id is runtime-independent
    • isIndependent

      public boolean isIndependent()
      Checks if the passed custom id is runtime-independent.
      Returns:
      true if the custom id is runtime-independent
    • isBound

      public boolean isBound()
      Checks if the passed custom id is runtime-bound.
      Returns:
      true if the custom id is runtime-bound
    • 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.
    • definitionId

      @NotNull public @NotNull String definitionId()
      Returns the value of the definitionId record component.
      Returns:
      the value of the definitionId record component