Record Class InteractionRegistry

java.lang.Object
java.lang.Record
com.github.kaktushose.jda.commands.definitions.interactions.InteractionRegistry

public record InteractionRegistry(@NotNull DependencyInjector dependencyInjector, @NotNull com.github.kaktushose.jda.commands.dispatching.validation.internal.Validators validators, @NotNull LocalizationFunction localizationFunction, @NotNull Descriptor descriptor, @NotNull Set<Definition> definitions) extends Record
Central registry for all InteractionDefinitions.
  • Constructor Details

    • InteractionRegistry

      public InteractionRegistry(DependencyInjector injector, com.github.kaktushose.jda.commands.dispatching.validation.internal.Validators registry, LocalizationFunction function, Descriptor descriptor)
      Constructs a new InteractionRegistry
      Parameters:
      injector - the DependencyInjector to use
      registry - the corresponding Validators
      function - the LocalizationFunction to use
      descriptor - the Descriptor to use
    • InteractionRegistry

      public InteractionRegistry(@NotNull @NotNull DependencyInjector dependencyInjector, @NotNull @NotNull com.github.kaktushose.jda.commands.dispatching.validation.internal.Validators validators, @NotNull @NotNull LocalizationFunction localizationFunction, @NotNull @NotNull Descriptor descriptor, @NotNull @NotNull Set<Definition> definitions)
      Creates an instance of a InteractionRegistry record class.
      Parameters:
      dependencyInjector - the value for the dependencyInjector record component
      validators - the value for the validators record component
      localizationFunction - the value for the localizationFunction record component
      descriptor - the value for the descriptor record component
      definitions - the value for the definitions record component
  • Method Details

    • index

      public void index(Iterable<Class<?>> classes)
      Scans all given classes and registers the interactions defined in them.
      Parameters:
      classes - the Classes to build the interactions from
    • find

      public <T extends Definition> T find(Class<T> type, boolean internalError, Predicate<T> predicate)
      Attempts to find a Definition of type InteractionRegistry based on the given Predicate.
      Type Parameters:
      T - a subtype of Definition
      Parameters:
      type - the type of the Definition to find
      internalError - true if the Definition must be found and not finding it indicates a framework bug
      predicate - the Predicate used to find the Definition
      Returns:
      InteractionRegistry
      Throws:
      IllegalStateException - if no Definition was found, although this mandatory should have been the case. This is a rare occasion and can be considered a framework bug
      IllegalArgumentException - if no Definition was found, because the Predicate didn't include any elements
    • find

      public <T extends Definition> Collection<T> find(Class<T> type, Predicate<T> predicate)
      Attempts to find all Definitions of type InteractionRegistry based on the given Predicate.
      Type Parameters:
      T - a subtype of Definition
      Parameters:
      type - the type of the Definition to find indicates a framework bug
      predicate - the Predicate used to find the Definitions
      Returns:
      a possibly-empty Collection of all Definitions that match the given Predicate
      Throws:
      IllegalStateException - if no Definition was found, although this mandatory should have been the case. This is a rare occasion and can be considered a framework bug
      IllegalArgumentException - if no Definition was found, because the Predicate didn't include any elements
    • 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.
    • dependencyInjector

      @NotNull public @NotNull DependencyInjector dependencyInjector()
      Returns the value of the dependencyInjector record component.
      Returns:
      the value of the dependencyInjector record component
    • validators

      @NotNull public @NotNull com.github.kaktushose.jda.commands.dispatching.validation.internal.Validators validators()
      Returns the value of the validators record component.
      Returns:
      the value of the validators record component
    • localizationFunction

      @NotNull public @NotNull LocalizationFunction localizationFunction()
      Returns the value of the localizationFunction record component.
      Returns:
      the value of the localizationFunction record component
    • descriptor

      @NotNull public @NotNull Descriptor descriptor()
      Returns the value of the descriptor record component.
      Returns:
      the value of the descriptor record component
    • definitions

      @NotNull public @NotNull Set<Definition> definitions()
      Returns the value of the definitions record component.
      Returns:
      the value of the definitions record component