Record Class InteractionRegistry
java.lang.Object
java.lang.Record
io.github.kaktushose.jdac.definitions.interactions.InteractionRegistry
- All Implemented Interfaces:
Definitions
public record InteractionRegistry(Validators validators, I18n i18n, net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction localizationFunction, Descriptor descriptor, Set<InteractionDefinition> definitions)
extends Record
implements Definitions
Central registry for all
InteractionDefinitions.-
Constructor Summary
ConstructorsConstructorDescriptionInteractionRegistry(Validators registry, I18n i18n, net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction function, Descriptor descriptor) Constructs a newInteractionRegistryInteractionRegistry(Validators validators, I18n i18n, net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction localizationFunction, Descriptor descriptor, Set<InteractionDefinition> definitions) Creates an instance of aInteractionRegistryrecord class. -
Method Summary
Modifier and TypeMethodDescriptionall()Gets allInteractionDefinitions that were indexed by JDA-Commands.Returns the value of thedefinitionsrecord component.Returns the value of thedescriptorrecord component.final booleanIndicates whether some other object is "equal to" this one.<T extends Definition>
T<T extends Definition>
Collection<T> <T extends Definition>
TGets the first
InteractionDefinitionwith the giventhatinvalid reference
type
match the passed
Predicatefinal inthashCode()Returns a hash code value for this object.i18n()Returns the value of thei18nrecord component.voidindex(Iterable<Class<?>> classes, CommandDefinition.CommandConfig globalCommandConfig) Scans all given classes and registers the interactions defined in them.net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunctionReturns the value of thelocalizationFunctionrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalidatorsrecord component.
-
Constructor Details
-
InteractionRegistry
public InteractionRegistry(Validators registry, I18n i18n, net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction function, Descriptor descriptor) Constructs a newInteractionRegistry- Parameters:
registry- the correspondingValidatorsi18n- theI18ninstance to usefunction- theLocalizationFunctionto usedescriptor- theDescriptorto use
-
InteractionRegistry
public InteractionRegistry(Validators validators, I18n i18n, net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction localizationFunction, Descriptor descriptor, Set<InteractionDefinition> definitions) Creates an instance of aInteractionRegistryrecord class.- Parameters:
validators- the value for thevalidatorsrecord componenti18n- the value for thei18nrecord componentlocalizationFunction- the value for thelocalizationFunctionrecord componentdescriptor- the value for thedescriptorrecord componentdefinitions- the value for thedefinitionsrecord component
-
-
Method Details
-
index
Scans all given classes and registers the interactions defined in them.- Parameters:
classes- theClasses to build the interactions from
-
find
- Type Parameters:
T- a subtype ofDefinition- Parameters:
type- the type of theDefinitionto findinternalError-trueif theDefinitionmust be found and not finding it indicates a framework bugpredicate- thePredicateused to find theDefinition- Returns:
Tthe definition- Throws:
IllegalStateException- if noDefinitionwas found, although this mandatory should have been the case. This is a rare occasion and can be considered a framework bugIllegalArgumentException- if noDefinitionwas found, because thePredicatedidn't include any elements
-
findFirst
Description copied from interface:DefinitionsGets the first
InteractionDefinitionwith the giventhatinvalid reference
type
match the passed
Predicate- Specified by:
findFirstin interfaceDefinitions- Parameters:
type-the
of the neededinvalid reference
type
InteractionDefinitionpredicate- thePredicatethat has to match the neededInteractionDefinition- Returns:
- the frist
InteractionDefinitionmatching the provided criteria
-
find
- Specified by:
findin interfaceDefinitions- Type Parameters:
T- a subtype ofDefinition- Parameters:
type- the type of theDefinitionto findpredicate- thePredicateused to find theDefinitions- Returns:
- a possibly-empty
Collectionof allDefinitions that match the givenPredicate - Throws:
IllegalStateException- if noDefinitionwas found, although this mandatory should have been the case. This is a rare occasion and can be considered a framework bugIllegalArgumentException- if noDefinitionwas found, because thePredicatedidn't include any elements
-
all
Description copied from interface:DefinitionsGets allInteractionDefinitions that were indexed by JDA-Commands.- Specified by:
allin interfaceDefinitions- Returns:
- an immutable collection of all indexes
InteractionDefinitions
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
validators
Returns the value of thevalidatorsrecord component.- Returns:
- the value of the
validatorsrecord component
-
i18n
Returns the value of thei18nrecord component.- Returns:
- the value of the
i18nrecord component
-
localizationFunction
public net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction localizationFunction()Returns the value of thelocalizationFunctionrecord component.- Returns:
- the value of the
localizationFunctionrecord component
-
descriptor
Returns the value of thedescriptorrecord component.- Returns:
- the value of the
descriptorrecord component
-
definitions
Returns the value of thedefinitionsrecord component.- Returns:
- the value of the
definitionsrecord component
-