Record Class Implementation<T extends Implementation.ExtensionProvidable>

java.lang.Object
java.lang.Record
com.github.kaktushose.jda.commands.extension.Implementation<T>
Record Components:
type - the Class of the implemented interface
supplier - the Function used to retrieve instances of the custom implementation

public record Implementation<T extends Implementation.ExtensionProvidable>(@NotNull Class<T extends Implementation.ExtensionProvidable> type, @NotNull Function<@NotNull JDACBuilderData,@NotNull SequencedCollection<@NotNull T extends Implementation.ExtensionProvidable>> supplier) extends Record

Instances of Implementation are used to provide custom implementations of Implementation.ExtensionProvidable interfaces, namely:

Such instances of Implementation are returned by Extension.providedImplementations() and used by the JDACBuilder to configure jda-commands.

Note: If the supplier() returns an empty collection, then this Implementation is discarded and thus treated as non-existent.

See Also:
  • Constructor Details

    • Implementation

      public Implementation(@NotNull @NotNull Class<T> type, @NotNull @NotNull Function<@NotNull JDACBuilderData,@NotNull SequencedCollection<@NotNull T>> supplier)
      Creates an instance of a Implementation record class.
      Parameters:
      type - the value for the type record component
      supplier - the value for the supplier record component
  • Method Details

    • single

      public static <T extends Implementation.ExtensionProvidable> Implementation<T> single(@NotNull @NotNull Class<T> type, @NotNull @NotNull Function<@NotNull JDACBuilderData,@NotNull T> supplier)
    • 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.
    • type

      @NotNull public @NotNull Class<T> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • supplier

      @NotNull public @NotNull Function<@NotNull JDACBuilderData,@NotNull SequencedCollection<@NotNull T>> supplier()
      Returns the value of the supplier record component.
      Returns:
      the value of the supplier record component