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

io.github.dehuckakpyt.telegrambot.context.SpringContext.kt Maven / Gradle / Ivy

There is a newer version: 0.11.5b
Show newest version
package io.github.dehuckakpyt.telegrambot.context

import org.springframework.context.ApplicationContext


/**
 * Created on 29.12.2023.
 *

* * @author Denis Matytsin */ //TODO remove this bad code @Deprecated("Will be remove in future release.") object SpringContext { lateinit var context: ApplicationContext // inline fun inject(name: String? = null): ReadOnlyProperty = inject(T::class.java, name) // fun inject(type: Class, name: String? = null): ReadOnlyProperty = Inject(type, name) // // private class Inject( // private val type: Class, // private val name: String?, // ) : ReadOnlyProperty { // // private val value by lazy { if (name == null) context.getBean(type) else context.getBean(name, type) } // override operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value // } inline fun autowired(name: String? = null): T = autowired(T::class.java, name) fun autowired(type: Class, name: String? = null): T = if (name == null) context.getBean(type) else context.getBean(name, type) }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy