22 lines
840 B
Kotlin
22 lines
840 B
Kotlin
package commands
|
|
|
|
import collection.CollectionManager
|
|
import kotlinx.serialization.Contextual
|
|
import kotlinx.serialization.Serializable
|
|
import models.HumanBeing
|
|
import network.Response
|
|
|
|
/**
|
|
* Выводит любой элемент с минимальным значением поля [HumanBeing.name].
|
|
*/
|
|
@Serializable
|
|
class MinByNameCommand(@Contextual private val manager: CollectionManager) : Command {
|
|
override val name = "min_by_name"
|
|
override val description = "вывести элемент с минимальным именем"
|
|
override val type = CommandType.SIMPLE
|
|
override val args = listOf(CommandArgType.NONE)
|
|
|
|
override fun execute(args: List<String>, humanBeing: HumanBeing?, userId: String): Response =
|
|
Response(true, manager.minByName()?.toString() ?: "Коллекция пуста.")
|
|
}
|