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, MessageResolver messageResolver, Descriptor descriptor, Set<InteractionDefinition> definitions)
extends Record
implements Definitions
Central registry for all
InteractionDefinitions.-
Constructor Summary
ConstructorsConstructorDescriptionInteractionRegistry(Validators registry, MessageResolver messageResolver, Descriptor descriptor) Constructs a newInteractionRegistryInteractionRegistry(Validators validators, MessageResolver messageResolver, 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>
SequencedCollection<T> <T extends Definition>
Tfinal inthashCode()Returns a hash code value for this object.voidindex(Iterable<Class<?>> classes, CommandDefinition.CommandConfig globalCommandConfig) Scans all given classes and registers the interactions defined in them.Returns the value of themessageResolverrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalidatorsrecord component.Methods inherited from interface Definitions
find
-
Constructor Details
-
InteractionRegistry
public InteractionRegistry(Validators registry, MessageResolver messageResolver, Descriptor descriptor) Constructs a newInteractionRegistry- Parameters:
registry- the correspondingValidatorsmessageResolver- theMessageResolverinstance to usedescriptor- theDescriptorto use
-
InteractionRegistry
public InteractionRegistry(Validators validators, MessageResolver messageResolver, Descriptor descriptor, Set<InteractionDefinition> definitions) Creates an instance of aInteractionRegistryrecord class.- Parameters:
validators- the value for thevalidatorsrecord componentmessageResolver- the value for themessageResolverrecord 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:Definitions- Specified by:
findFirstin interfaceDefinitions- Parameters:
type- the type of the neededInteractionDefinitionpredicate- 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
-
messageResolver
Returns the value of themessageResolverrecord component.- Returns:
- the value of the
messageResolverrecord 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
-