All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kr.summitsystems.springbukkit.command.CommandExceptionHandlerRegistryImpl.kt Maven / Gradle / Ivy

The newest version!
package kr.summitsystems.springbukkit.command

import org.springframework.beans.factory.config.BeanDefinition
import org.springframework.context.annotation.Role
import org.springframework.core.convert.TypeDescriptor
import org.springframework.stereotype.Component

@Component
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
internal class CommandExceptionHandlerRegistryImpl : CommandExceptionHandlerRegistry {
    private val handlers: MutableMap = mutableMapOf()

    override fun addExceptionHandler(registrableCommandExceptionHandler: RegistrableCommandExceptionHandler) {
        handlers[registrableCommandExceptionHandler.throwableType] = registrableCommandExceptionHandler
    }

    override fun find(throwableType: TypeDescriptor): RegistrableCommandExceptionHandler? {
        return handlers[throwableType]
    }

    override fun getOrderedExceptionHandlers(): List {
        return handlers
            .values
            .sortedBy {
                it.order
            }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy