From 7012fe0f6214c262126f112154d5765a4c5e4f43 Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 16 Nov 2020 15:36:55 +0800 Subject: [PATCH] Make subclasses of AbstractCommandValueParameter data classes --- .../src/command/descriptor/CommandParameter.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/mirai-console/src/command/descriptor/CommandParameter.kt b/backend/mirai-console/src/command/descriptor/CommandParameter.kt index 160d02752..01f4b3533 100644 --- a/backend/mirai-console/src/command/descriptor/CommandParameter.kt +++ b/backend/mirai-console/src/command/descriptor/CommandParameter.kt @@ -165,10 +165,11 @@ public sealed class AbstractCommandValueParameter : CommandValueParameter, } @ConsoleExperimentalApi - public class StringConstant( + public data class StringConstant( @ConsoleExperimentalApi public override val name: String?, public val expectingValue: String, + public val ignoreCase: Boolean, ) : AbstractCommandValueParameter() { public override val type: KType get() = STRING_TYPE public override val isOptional: Boolean get() = false @@ -186,7 +187,7 @@ public sealed class AbstractCommandValueParameter : CommandValueParameter, override fun toString(): String = "<$expectingValue>" override fun acceptingImpl(expectingType: KType, argument: CommandValueArgument, commandArgumentContext: CommandArgumentContext?): ArgumentAcceptance { - return if (argument.value.content == expectingValue) { + return if (argument.value.content.equals(expectingValue, ignoreCase)) { ArgumentAcceptance.Direct } else ArgumentAcceptance.Impossible } @@ -201,7 +202,7 @@ public sealed class AbstractCommandValueParameter : CommandValueParameter, * @see createOptional * @see createRequired */ - public class UserDefinedType( + public data class UserDefinedType( public override val name: String?, public override val isOptional: Boolean, public override val isVararg: Boolean,