Record Class InteractionRegistry

java.lang.Object
java.lang.Record
io.github.kaktushose.jdac.definitions.interactions.InteractionRegistry

public record InteractionRegistry(Validators validators, I18n i18n, LocalizationFunction localizationFunction, Descriptor descriptor, Set<Definition> definitions) extends Record
Central registry for all InteractionDefinitions.
  • Constructor Details

    • InteractionRegistry

      public InteractionRegistry(Validators registry, I18n i18n, LocalizationFunction function, Descriptor descriptor)
      Constructs a new InteractionRegistry
      Parameters:
      registry - the corresponding Validators
      i18n - the I18n instance to use
      function - the LocalizationFunction to use
      descriptor - the Descriptor to use
    • InteractionRegistry

      public InteractionRegistry(Validators validators, I18n i18n, LocalizationFunction localizationFunction, Descriptor descriptor, Set<Definition> definitions)
      Creates an instance of a InteractionRegistry record class.
      Parameters:
      validators - the value for the validators record component
      i18n - the value for the i18n 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, CommandDefinition.CommandConfig globalCommandConfig)
      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 T 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:
      T the definition
      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 T based on the given Predicate.
      Type Parameters:
      T - a subtype of Definition
      Parameters:
      type - the type of the Definition to find
      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.
    • validators

      public Validators validators()
      Returns the value of the validators record component.
      Returns:
      the value of the validators record component
    • i18n

      public I18n i18n()
      Returns the value of the i18n record component.
      Returns:
      the value of the i18n record component
    • localizationFunction

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

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

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