Remove KClass based Kotlin extensions

Issue: SPR-15660
This commit is contained in:
Sebastien Deleuze
2017-06-13 18:43:59 +02:00
parent 223315f96b
commit 04d5a2951c
18 changed files with 11 additions and 441 deletions

View File

@@ -1,15 +1,5 @@
package org.springframework.beans.factory
import kotlin.reflect.KClass
/**
* Extension for [BeanFactory.getBean] providing a [KClass] based variant.
*
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>): T = getBean(requiredType.java)
/**
* Extension for [BeanFactory.getBean] providing a `getBean<Foo>()` variant.
@@ -30,16 +20,6 @@ inline fun <reified T : Any> BeanFactory.getBean(): T = getBean(T::class.java)
inline fun <reified T : Any> BeanFactory.getBean(name: String): T =
getBean(name, T::class.java)
/**
* Extension for [BeanFactory.getBean] providing a [KClass] based variant.
*
* @see BeanFactory.getBean(Class<T>, Object...)
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>, vararg args:Any): T =
getBean(requiredType.java, *args)
/**
* Extension for [BeanFactory.getBean] providing a `getBean<Foo>(arg1, arg2)` variant.
*

View File

@@ -1,18 +1,5 @@
package org.springframework.beans.factory
import kotlin.reflect.KClass
/**
* Extension for [ListableBeanFactory.getBeanNamesForType] providing a [KClass] based variant.
*
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Any> ListableBeanFactory.getBeanNamesForType(type: KClass<T>,
includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array<out String> =
getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit)
/**
* Extension for [ListableBeanFactory.getBeanNamesForType] providing a `getBeanNamesForType<Foo>()` variant.
*
@@ -22,15 +9,6 @@ fun <T : Any> ListableBeanFactory.getBeanNamesForType(type: KClass<T>,
inline fun <reified T : Any> ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array<out String> =
getBeanNamesForType(T::class.java, includeNonSingletons, allowEagerInit)
/**
* Extension for [ListableBeanFactory.getBeansOfType] providing a [KClass] based variant.
*
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Any> ListableBeanFactory.getBeansOfType(type: KClass<T>, includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map<String, Any> =
getBeansOfType(type.java, includeNonSingletons, allowEagerInit)
/**
* Extension for [ListableBeanFactory.getBeansOfType] providing a `getBeansOfType<Foo>()` variant.
*
@@ -40,15 +18,6 @@ fun <T : Any> ListableBeanFactory.getBeansOfType(type: KClass<T>, includeNonSing
inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map<String, Any> =
getBeansOfType(T::class.java, includeNonSingletons, allowEagerInit)
/**
* Extension for [ListableBeanFactory.getBeanNamesForAnnotation] providing a [KClass] based variant.
*
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(type: KClass<T>): Array<out String> =
getBeanNamesForAnnotation(type.java)
/**
* Extension for [ListableBeanFactory.getBeanNamesForAnnotation] providing a `getBeansOfType<Foo>()` variant.
*
@@ -58,15 +27,6 @@ fun <T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(type: KClass<
inline fun <reified T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(): Array<out String> =
getBeanNamesForAnnotation(T::class.java)
/**
* Extension for [ListableBeanFactory.getBeansWithAnnotation] providing a [KClass] based variant.
*
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Annotation> ListableBeanFactory.getBeansWithAnnotation(type: KClass<T>): MutableMap<String, Any> =
getBeansWithAnnotation(type.java)
/**
* Extension for [ListableBeanFactory.getBeansWithAnnotation] providing a `getBeansWithAnnotation<Foo>()` variant.
*
@@ -76,15 +36,6 @@ fun <T : Annotation> ListableBeanFactory.getBeansWithAnnotation(type: KClass<T>)
inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation(): MutableMap<String, Any> =
getBeansWithAnnotation(T::class.java)
/**
* Extension for [ListableBeanFactory.findAnnotationOnBean] providing a [KClass] based variant.
*
* @author Sebastien Deleuze
* @since 5.0
*/
fun <T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass<T>): Annotation? =
findAnnotationOnBean(beanName, type.java)
/**
* Extension for [ListableBeanFactory.findAnnotationOnBean] providing a `findAnnotationOnBean<Foo>("foo")` variant.
*