Remove object wrappers in Kotlin extensions
This commit also improve significantly Kotlin extensions documentation. Issue: SPR-15127
This commit is contained in:
parent
4f1fe74912
commit
0a988fd2b1
|
|
@ -1,47 +0,0 @@
|
||||||
package org.springframework.beans.factory
|
|
||||||
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [BeanFactory] providing [KClass] based API.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object BeanFactoryExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BeanFactory.getBean(Class<T>)
|
|
||||||
*/
|
|
||||||
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>) = getBean(requiredType.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BeanFactory.getBean(Class<T>)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> BeanFactory.getBean() = getBean(T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BeanFactory.getBean(String, Class<T>)
|
|
||||||
*/
|
|
||||||
fun <T : Any> BeanFactory.getBean(name: String, requiredType: KClass<T>) =
|
|
||||||
getBean(name, requiredType.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BeanFactory.getBean(String, Class<T>)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> BeanFactory.getBean(name: String) =
|
|
||||||
getBean(name, T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BeanFactory.getBean(Class<T>, Object...)
|
|
||||||
*/
|
|
||||||
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>, vararg args:Any) =
|
|
||||||
getBean(requiredType.java, *args)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BeanFactory.getBean(Class<T>, Object...)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> BeanFactory.getBean(vararg args:Any) =
|
|
||||||
getBean(T::class.java, *args)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
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>) = getBean(requiredType.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [BeanFactory.getBean] providing a `getBean<Foo>()` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> BeanFactory.getBean() = getBean(T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [BeanFactory.getBean] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @see BeanFactory.getBean(String, Class<T>)
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> BeanFactory.getBean(name: String, requiredType: KClass<T>) =
|
||||||
|
getBean(name, requiredType.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [BeanFactory.getBean] providing a `getBean<Foo>("foo")` variant.
|
||||||
|
*
|
||||||
|
* @see BeanFactory.getBean(String, Class<T>)
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> BeanFactory.getBean(name: String) =
|
||||||
|
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) =
|
||||||
|
getBean(requiredType.java, *args)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [BeanFactory.getBean] providing a `getBean<Foo>(arg1, arg2)` variant.
|
||||||
|
*
|
||||||
|
* @see BeanFactory.getBean(Class<T>, Object...)
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> BeanFactory.getBean(vararg args:Any) =
|
||||||
|
getBean(T::class.java, *args)
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
package org.springframework.beans.factory
|
|
||||||
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [ListableBeanFactory] providing [KClass] based API.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object ListableBeanFactoryExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeanNamesForType(Class<?>, boolean, boolean)
|
|
||||||
*/
|
|
||||||
fun <T : Any> ListableBeanFactory.getBeanNamesForType(type: KClass<T>,
|
|
||||||
includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
|
||||||
getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeanNamesForType(Class<?>, boolean, boolean)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
|
||||||
getBeanNamesForType(T::class.java, includeNonSingletons, allowEagerInit)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeansOfType(Class<T>, boolean, boolean)
|
|
||||||
*/
|
|
||||||
fun <T : Any> ListableBeanFactory.getBeansOfType(type: KClass<T>,
|
|
||||||
includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
|
||||||
getBeansOfType(type.java, includeNonSingletons, allowEagerInit)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeansOfType(Class<T>, boolean, boolean)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
|
||||||
getBeansOfType(T::class.java, includeNonSingletons, allowEagerInit)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeanNamesForAnnotation
|
|
||||||
*/
|
|
||||||
fun <T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(type: KClass<T>) =
|
|
||||||
getBeanNamesForAnnotation(type.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeanNamesForAnnotation
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation() =
|
|
||||||
getBeanNamesForAnnotation(T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeansWithAnnotation
|
|
||||||
*/
|
|
||||||
fun <T : Annotation> ListableBeanFactory.getBeansWithAnnotation(type: KClass<T>) =
|
|
||||||
getBeansWithAnnotation(type.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactory.getBeansWithAnnotation
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation() =
|
|
||||||
getBeansWithAnnotation(T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactoryExtension.findAnnotationOnBean
|
|
||||||
*/
|
|
||||||
fun <T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass<T>) =
|
|
||||||
findAnnotationOnBean(beanName, type.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListableBeanFactoryExtension.findAnnotationOnBean
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String) =
|
|
||||||
findAnnotationOnBean(beanName, T::class.java)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
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) =
|
||||||
|
getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ListableBeanFactory.getBeanNamesForType] providing a `getBeanNamesForType<Foo>()` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
||||||
|
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) =
|
||||||
|
getBeansOfType(type.java, includeNonSingletons, allowEagerInit)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ListableBeanFactory.getBeansOfType] providing a `getBeansOfType<Foo>()` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
||||||
|
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>) =
|
||||||
|
getBeanNamesForAnnotation(type.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ListableBeanFactory.getBeanNamesForAnnotation] providing a `getBeansOfType<Foo>()` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation() =
|
||||||
|
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>) =
|
||||||
|
getBeansWithAnnotation(type.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ListableBeanFactory.getBeansWithAnnotation] providing a `getBeansWithAnnotation<Foo>()` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation() =
|
||||||
|
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>) =
|
||||||
|
findAnnotationOnBean(beanName, type.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ListableBeanFactory.findAnnotationOnBean] providing a `findAnnotationOnBean<Foo>("foo")` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String) =
|
||||||
|
findAnnotationOnBean(beanName, T::class.java)
|
||||||
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
package org.springframework.context.annotation
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [AnnotationConfigApplicationContext] providing
|
|
||||||
* `AnnotationConfigApplicationContext { }` style initialization.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object AnnotationConfigApplicationContextExtension {
|
|
||||||
|
|
||||||
fun AnnotationConfigApplicationContext(configure: AnnotationConfigApplicationContext.()->Unit) =
|
|
||||||
AnnotationConfigApplicationContext().apply(configure)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.springframework.context.annotation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [AnnotationConfigApplicationContext] allowing
|
||||||
|
* `AnnotationConfigApplicationContext { ... }` style initialization.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun AnnotationConfigApplicationContext(configure: AnnotationConfigApplicationContext.()->Unit) =
|
||||||
|
AnnotationConfigApplicationContext().apply(configure)
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
package org.springframework.context.support
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinitionCustomizer
|
|
||||||
import org.springframework.context.ApplicationContext
|
|
||||||
import java.util.function.Supplier
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [GenericApplicationContext] providing [KClass] based API and
|
|
||||||
* avoiding specifying a class parameter for the [Supplier] based variant thanks to
|
|
||||||
* Kotlin reified type parameters.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object GenericApplicationContextExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GenericApplicationContext.registerBean(Class<T>, BeanDefinitionCustomizer...)
|
|
||||||
*/
|
|
||||||
fun <T : Any> GenericApplicationContext.registerBean(beanClass: KClass<T>,
|
|
||||||
vararg customizers: BeanDefinitionCustomizer) {
|
|
||||||
registerBean(beanClass.java, *customizers)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GenericApplicationContext.registerBean(Class<T>, BeanDefinitionCustomizer...)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> GenericApplicationContext.registerBean(vararg customizers: BeanDefinitionCustomizer) {
|
|
||||||
registerBean(T::class.java, *customizers)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GenericApplicationContext.registerBean(String, Class<T>, BeanDefinitionCustomizer...)
|
|
||||||
*/
|
|
||||||
fun <T : Any> GenericApplicationContext.registerBean(beanName: String, beanClass: KClass<T>,
|
|
||||||
vararg customizers: BeanDefinitionCustomizer) {
|
|
||||||
registerBean(beanName, beanClass.java, *customizers)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GenericApplicationContext.registerBean(String, Class<T>, BeanDefinitionCustomizer...)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> GenericApplicationContext.registerBean(beanName: String, vararg customizers: BeanDefinitionCustomizer) {
|
|
||||||
registerBean(beanName, T::class.java, *customizers)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GenericApplicationContext.registerBean(Class<T>, Supplier<T>, BeanDefinitionCustomizer...)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> GenericApplicationContext.registerBean(
|
|
||||||
vararg customizers: BeanDefinitionCustomizer, crossinline function: (ApplicationContext) -> T) {
|
|
||||||
registerBean(T::class.java, Supplier { function.invoke(this) }, *customizers)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GenericApplicationContext.registerBean(String, Class<T>, Supplier<T>, BeanDefinitionCustomizer...)
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> GenericApplicationContext.registerBean(name: String,
|
|
||||||
vararg customizers: BeanDefinitionCustomizer, crossinline function: (ApplicationContext) -> T) {
|
|
||||||
registerBean(name, T::class.java, Supplier { function.invoke(this) }, *customizers)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun GenericApplicationContext(configure: GenericApplicationContext.()->Unit) = GenericApplicationContext().apply(configure)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package org.springframework.context.support
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinitionCustomizer
|
||||||
|
import org.springframework.context.ApplicationContext
|
||||||
|
import java.util.function.Supplier
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext.registerBean] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> GenericApplicationContext.registerBean(beanClass: KClass<T>,
|
||||||
|
vararg customizers: BeanDefinitionCustomizer) {
|
||||||
|
registerBean(beanClass.java, *customizers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext.registerBean] providing a `registerBean<Foo>()` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> GenericApplicationContext.registerBean(vararg customizers: BeanDefinitionCustomizer) {
|
||||||
|
registerBean(T::class.java, *customizers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext.registerBean] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> GenericApplicationContext.registerBean(beanName: String, beanClass: KClass<T>,
|
||||||
|
vararg customizers: BeanDefinitionCustomizer) {
|
||||||
|
registerBean(beanName, beanClass.java, *customizers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext.registerBean] providing a `registerBean<Foo>("foo")` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> GenericApplicationContext.registerBean(beanName: String, vararg customizers: BeanDefinitionCustomizer) {
|
||||||
|
registerBean(beanName, T::class.java, *customizers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext.registerBean] providing a `registerBean { Foo() }` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> GenericApplicationContext.registerBean(
|
||||||
|
vararg customizers: BeanDefinitionCustomizer, crossinline function: (ApplicationContext) -> T) {
|
||||||
|
registerBean(T::class.java, Supplier { function.invoke(this) }, *customizers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext.registerBean] providing a `registerBean("foo") { Foo() }` variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> GenericApplicationContext.registerBean(name: String,
|
||||||
|
vararg customizers: BeanDefinitionCustomizer, crossinline function: (ApplicationContext) -> T) {
|
||||||
|
registerBean(name, T::class.java, Supplier { function.invoke(this) }, *customizers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [GenericApplicationContext] allowing `GenericApplicationContext { ... }` style initialization.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun GenericApplicationContext(configure: GenericApplicationContext.()->Unit) = GenericApplicationContext().apply(configure)
|
||||||
|
|
||||||
|
|
@ -17,22 +17,15 @@
|
||||||
package org.springframework.ui
|
package org.springframework.ui
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension for [Model] providing idiomatic Kotlin API
|
* Extension for [Model.addAttribute] providing Array like setter.
|
||||||
*
|
|
||||||
* @author Mario Arias
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object ModelExtension {
|
|
||||||
|
|
||||||
/** Array like setter for [Model]
|
|
||||||
*
|
*
|
||||||
* ```kotlin
|
* ```kotlin
|
||||||
* model["firstName"] = "Mario"
|
* model["firstName"] = "Mario"
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @see Model.addAttribute
|
* @author Mario Arias
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
operator fun Model.set(attributeName: String, attributeValue: Any) {
|
operator fun Model.set(attributeName: String, attributeValue: Any) {
|
||||||
this.addAttribute(attributeName, attributeValue)
|
this.addAttribute(attributeName, attributeValue)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,22 +17,16 @@
|
||||||
package org.springframework.ui
|
package org.springframework.ui
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension for [ModelMap] providing idiomatic Kotlin API
|
|
||||||
*
|
*
|
||||||
* @author Mario Arias
|
* Extension for [ModelMap] providing Array like setter.
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object ModelMapExtension {
|
|
||||||
|
|
||||||
/** Array like setter for [ModelMap]
|
|
||||||
*
|
*
|
||||||
* ```kotlin
|
* ```kotlin
|
||||||
* model["firstName"] = "Mario"
|
* model["firstName"] = "Mario"
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @see ModelMap.addAttribute
|
* @author Mario Arias
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
operator fun ModelMap.set(attributeName: String, attributeValue: Any) {
|
operator fun ModelMap.set(attributeName: String, attributeValue: Any) {
|
||||||
this.addAttribute(attributeName, attributeValue)
|
this.addAttribute(attributeName, attributeValue)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,11 +2,9 @@ package org.springframework.context.support
|
||||||
|
|
||||||
import org.junit.Assert.assertNotNull
|
import org.junit.Assert.assertNotNull
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.springframework.context.support.GenericApplicationContextExtension.registerBean
|
import org.springframework.beans.factory.getBean
|
||||||
import org.springframework.beans.factory.BeanFactoryExtension.getBean
|
|
||||||
import org.springframework.context.support.GenericApplicationContextExtension.GenericApplicationContext
|
|
||||||
|
|
||||||
class GenericApplicationContextExtensionTests {
|
class GenericApplicationContextExtensionsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun registerBeanWithClass() {
|
fun registerBeanWithClass() {
|
||||||
|
|
@ -19,10 +19,9 @@ package org.springframework.ui
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.springframework.ui.ModelExtension.set
|
|
||||||
|
|
||||||
|
|
||||||
class ModelExtensionTests {
|
class ModelExtensionsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setAttribute() {
|
fun setAttribute() {
|
||||||
|
|
@ -19,10 +19,9 @@ package org.springframework.ui
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.springframework.ui.ModelMapExtension.set
|
|
||||||
|
|
||||||
|
|
||||||
class ModelMapExtensionTests {
|
class ModelMapExtensionsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setAttribute() {
|
fun setAttribute() {
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
package org.springframework.web.reactive.function
|
|
||||||
|
|
||||||
import org.springframework.http.ReactiveHttpInputMessage
|
|
||||||
import reactor.core.publisher.Flux
|
|
||||||
import reactor.core.publisher.Mono
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [BodyExtactors] providing [KClass] based API and avoiding specifying
|
|
||||||
* a class parameter when possible thanks to Kotlin reified type parameters.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object BodyExtractorsExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BodyExtactors.toMono
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> toMono() : BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
|
||||||
BodyExtractors.toMono(T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BodyExtactors.toMono
|
|
||||||
*/
|
|
||||||
fun <T : Any> toMono(elementClass: KClass<T>) : BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
|
||||||
BodyExtractors.toMono(elementClass.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BodyExtactors.toFlux
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Any> toFlux() : BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
|
||||||
BodyExtractors.toFlux(T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BodyExtactors.toFlux
|
|
||||||
*/
|
|
||||||
fun <T : Any> toFlux(elementClass: KClass<T>) : BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
|
||||||
BodyExtractors.toFlux(elementClass.java)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.springframework.web.reactive.function
|
||||||
|
|
||||||
|
import org.springframework.http.ReactiveHttpInputMessage
|
||||||
|
import reactor.core.publisher.Flux
|
||||||
|
import reactor.core.publisher.Mono
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for providing a `toMono()` alternative to `BodyExtractors.toMono(Foo::class.java)`.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> toMono() : BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||||
|
BodyExtractors.toMono(T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for providing a `toMono(Foo::class)` alternative to `BodyExtractors.toMono(Foo::class.java)`.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> toMono(elementClass: KClass<T>) : BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||||
|
BodyExtractors.toMono(elementClass.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for providing a `toFlux()` alternative to `BodyExtractors.toFlux(Foo::class.java)`.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Any> toFlux() : BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||||
|
BodyExtractors.toFlux(T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for providing a `toFlux(Foo::class)` alternative to `BodyExtractors.toFlux(Foo::class.java)`.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> toFlux(elementClass: KClass<T>) : BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||||
|
BodyExtractors.toFlux(elementClass.java)
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package org.springframework.web.reactive.function
|
|
||||||
|
|
||||||
import org.reactivestreams.Publisher
|
|
||||||
import org.springframework.http.ReactiveHttpOutputMessage
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [BodyInserters] providing [KClass] based API and avoiding specifying
|
|
||||||
* a class parameter when possible thanks to Kotlin reified type parameters.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object BodyInsertersExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BodyInserters.fromPublisher
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Publisher<S>, reified S : Any> fromPublisher(publisher: T) : BodyInserter<T, ReactiveHttpOutputMessage> =
|
|
||||||
BodyInserters.fromPublisher(publisher, S::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see BodyInserters.fromServerSentEvents
|
|
||||||
*/
|
|
||||||
inline fun <reified T : Publisher<S>, reified S : Any> fromServerSentEvents(publisher: T) : BodyInserter<T, ServerHttpResponse> =
|
|
||||||
BodyInserters.fromServerSentEvents(publisher, S::class.java)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.springframework.web.reactive.function
|
||||||
|
|
||||||
|
import org.reactivestreams.Publisher
|
||||||
|
import org.springframework.http.ReactiveHttpOutputMessage
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for providing a `fromPublisher(publisher)` alternative to `BodyInserters.fromPublisher(publisher, Foo::class.java)`.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Publisher<S>, reified S : Any> fromPublisher(publisher: T) : BodyInserter<T, ReactiveHttpOutputMessage> =
|
||||||
|
BodyInserters.fromPublisher(publisher, S::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for providing a `fromServerSentEvents(publisher)` alternative to `BodyInserters.fromServerSentEvents(publisher, Foo::class.java)`.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Publisher<S>, reified S : Any> fromServerSentEvents(publisher: T) : BodyInserter<T, ServerHttpResponse> =
|
||||||
|
BodyInserters.fromServerSentEvents(publisher, S::class.java)
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package org.springframework.web.reactive.function.client
|
|
||||||
|
|
||||||
import reactor.core.publisher.Flux
|
|
||||||
import reactor.core.publisher.Mono
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [ClientResponse] providing [KClass] based API.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object ClientResponseExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ClientResponse.bodyToFlux
|
|
||||||
*/
|
|
||||||
fun <T : Any> ClientResponse.bodyToFlux(type: KClass<T>) : Flux<T> = bodyToFlux(type.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ClientResponse.bodyToMono
|
|
||||||
*/
|
|
||||||
fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>) : Mono<T> = bodyToMono(type.java)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.springframework.web.reactive.function.client
|
||||||
|
|
||||||
|
import reactor.core.publisher.Flux
|
||||||
|
import reactor.core.publisher.Mono
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ClientResponse.bodyToMono] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>) : Mono<T> = bodyToMono(type.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ClientResponse.bodyToFlux] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> ClientResponse.bodyToFlux(type: KClass<T>) : Flux<T> = bodyToFlux(type.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
package org.springframework.web.reactive.function.server
|
|
||||||
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [ServerRequest] providing [KClass] based API.
|
|
||||||
*
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object ServerRequestExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ServerRequest.bodyToMono
|
|
||||||
*/
|
|
||||||
fun <T : Any> ServerRequest.bodyToMono(type: KClass<T>) = bodyToMono(type.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ServerRequest.bodyToFlux
|
|
||||||
*/
|
|
||||||
fun <T : Any> ServerRequest.bodyToFlux(type: KClass<T>) = bodyToFlux(type.java)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.springframework.web.reactive.function.server
|
||||||
|
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ServerRequest.bodyToMono] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> ServerRequest.bodyToMono(type: KClass<T>) = bodyToMono(type.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [ServerRequest.bodyToFlux] providing a [KClass] based variant.
|
||||||
|
*
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
fun <T : Any> ServerRequest.bodyToFlux(type: KClass<T>) = bodyToFlux(type.java)
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
package org.springframework.web.client
|
|
||||||
|
|
||||||
import org.springframework.http.HttpEntity
|
|
||||||
import org.springframework.http.HttpMethod
|
|
||||||
import org.springframework.http.RequestEntity
|
|
||||||
import java.net.URI
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for [RestOperations] providing [KClass] based API and avoiding specifying
|
|
||||||
* a class parameter when possible thanks to Kotlin reified type parameters.
|
|
||||||
*
|
|
||||||
* @author Jon Schneider
|
|
||||||
* @author Sebastien Deleuze
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
object RestOperationsExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.getForObject
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.getForObject(url: String, vararg uriVariables: Any) =
|
|
||||||
getForObject(url, T::class.java, *uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.getForObject
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.getForObject(url: String, uriVariables: Map<String, Any?>) =
|
|
||||||
getForObject(url, T::class.java, uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.getForObject
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.getForObject(url: URI) =
|
|
||||||
getForObject(url, T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.getForEntity
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.getForEntity(url: String, vararg uriVariables: Any) =
|
|
||||||
getForEntity(url, T::class.java, *uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.postForObject
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any) =
|
|
||||||
postForObject(url, request, T::class.java, *uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.postForObject
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, uriVariables: Map<String, *>) =
|
|
||||||
postForObject(url, request, T::class.java, uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.postForObject
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any) =
|
|
||||||
postForObject(url, request, T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.postForEntity
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any) =
|
|
||||||
postForEntity(url, request, T::class.java, *uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.postForEntity
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, uriVariables: Map<String, *>) =
|
|
||||||
postForEntity(url, request, T::class.java, uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.postForEntity
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any) =
|
|
||||||
postForEntity(url, request, T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.exchange
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any) =
|
|
||||||
exchange(url, method, requestEntity, T::class.java, *uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.exchange
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map<String, *>) =
|
|
||||||
exchange(url, method, requestEntity, T::class.java, uriVariables)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.exchange
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>) =
|
|
||||||
exchange(url, method, requestEntity, T::class.java)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see RestOperations.exchange
|
|
||||||
*/
|
|
||||||
@Throws(RestClientException::class)
|
|
||||||
inline fun <reified T: Any> RestOperations.exchange(requestEntity: RequestEntity<*>) =
|
|
||||||
exchange(requestEntity, T::class.java)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
package org.springframework.web.client
|
||||||
|
|
||||||
|
import org.springframework.http.HttpEntity
|
||||||
|
import org.springframework.http.HttpMethod
|
||||||
|
import org.springframework.http.RequestEntity
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.getForObject] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.getForObject(url: String, vararg uriVariables: Any) =
|
||||||
|
getForObject(url, T::class.java, *uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.getForObject] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.getForObject(url: String, uriVariables: Map<String, Any?>) =
|
||||||
|
getForObject(url, T::class.java, uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.getForObject] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.getForObject(url: URI) =
|
||||||
|
getForObject(url, T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.getForEntity] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.getForEntity(url: String, vararg uriVariables: Any) =
|
||||||
|
getForEntity(url, T::class.java, *uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.postForObject] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any) =
|
||||||
|
postForObject(url, request, T::class.java, *uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.postForObject] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, uriVariables: Map<String, *>) =
|
||||||
|
postForObject(url, request, T::class.java, uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any) =
|
||||||
|
postForObject(url, request, T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.postForEntity] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any) =
|
||||||
|
postForEntity(url, request, T::class.java, *uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.postForEntity] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, uriVariables: Map<String, *>) =
|
||||||
|
postForEntity(url, request, T::class.java, uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.postForEntity] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any) =
|
||||||
|
postForEntity(url, request, T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.exchange] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any) =
|
||||||
|
exchange(url, method, requestEntity, T::class.java, *uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.exchange] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map<String, *>) =
|
||||||
|
exchange(url, method, requestEntity, T::class.java, uriVariables)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.exchange] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>) =
|
||||||
|
exchange(url, method, requestEntity, T::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for [RestOperations.exchange] avoiding specifying thanks to Kotlin reified type parameters.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Throws(RestClientException::class)
|
||||||
|
inline fun <reified T: Any> RestOperations.exchange(requestEntity: RequestEntity<*>) =
|
||||||
|
exchange(requestEntity, T::class.java)
|
||||||
Loading…
Reference in New Issue