java.lang.Object
java.lang.Record
dev.sympho.modular_commands.api.command.parameter.Parameter<T>
- Type Parameters:
T- The type of argument that is provided.- Record Components:
name- The name of the parameter.description- The description of the parameter.required- Whether the parameter must be provided to invoke the command.defaultValue- The default value for the parameter.parser- The parser to use to process received arguments.
public record Parameter<T extends @NonNull Object>(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name, @MatchesRegex("(?Us)^.{1,100}+$") String description, boolean required, @Nullable T extends @NonNull Object defaultValue, ArgumentParser<?,T extends @NonNull Object> parser)
extends Record
Specification for a parameter received for a command.
Irrespective of whether the command it is used with is compatible with interactions or not, all values must be compatible with the Discord API specification for command parameters.
- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionPattern for valid parameter descriptions in the Discord API.Pattern for valid parameter names in the Discord API. -
Constructor Summary
ConstructorsConstructorDescriptionParameter(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name, @MatchesRegex("(?Us)^.{1,100}+$") String description, boolean required, @Nullable T defaultValue, ArgumentParser<?, T> parser) Creates an instance of aParameterrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends @NonNull Object>
ParameterBuilder<T>builder()Creates a new builder.Returns the value of thedefaultValuerecord component.@MatchesRegex("(?Us)^.{1,100}+$") StringReturns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") Stringname()Returns the value of thenamerecord component.ArgumentParser<?,T> parser()Returns the value of theparserrecord component.booleanrequired()Returns the value of therequiredrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NAME_REGEX
Pattern for valid parameter names in the Discord API.- See Also:
-
DESCRIPTION_REGEX
Pattern for valid parameter descriptions in the Discord API.- See Also:
-
-
Constructor Details
-
Parameter
public Parameter(@MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name, @MatchesRegex("(?Us)^.{1,100}+$") String description, boolean required, @Nullable T defaultValue, ArgumentParser<?, T> parser) Creates an instance of aParameterrecord class.- Parameters:
name- the value for thenamerecord componentdescription- the value for thedescriptionrecord componentrequired- the value for therequiredrecord componentdefaultValue- the value for thedefaultValuerecord componentparser- the value for theparserrecord component
-
-
Method Details
-
builder
Creates a new builder.- Type Parameters:
T- The argument type.- Returns:
- The builder.
-
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. -
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. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
required
public boolean required()Returns the value of therequiredrecord component.- Returns:
- the value of the
requiredrecord component
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-
parser
Returns the value of theparserrecord component.- Returns:
- the value of the
parserrecord component
-