Avoid requiring it parameter in Kotlin bean DSL
By using function literals with receiver, we can avoid requiring lambda parameters for a shorter and nicer syntax. Based on a proposal from Joseph Taylor. Issue: SPR-15815
This commit is contained in:
@@ -89,7 +89,7 @@ open class BeanDefinitionDsl(val condition: (ConfigurableEnvironment) -> Boolean
|
||||
isLazyInit: Boolean? = null,
|
||||
isPrimary: Boolean? = null,
|
||||
isAutowireCandidate: Boolean? = null,
|
||||
crossinline function: (BeanDefinitionContext) -> T) {
|
||||
crossinline function: BeanDefinitionContext.() -> T) {
|
||||
|
||||
val customizer = BeanDefinitionCustomizer { bd ->
|
||||
scope?.let { bd.scope = scope.name.toLowerCase() }
|
||||
@@ -122,7 +122,7 @@ open class BeanDefinitionDsl(val condition: (ConfigurableEnvironment) -> Boolean
|
||||
* Take in account bean definitions enclosed in the provided lambda only when the
|
||||
* specified environment-based predicate is true.
|
||||
*/
|
||||
fun environment(condition: (ConfigurableEnvironment) -> Boolean, init: BeanDefinitionDsl.() -> Unit): BeanDefinitionDsl {
|
||||
fun environment(condition: ConfigurableEnvironment.() -> Boolean, init: BeanDefinitionDsl.() -> Unit): BeanDefinitionDsl {
|
||||
val beans = BeanDefinitionDsl(condition::invoke)
|
||||
beans.init()
|
||||
children.add(beans)
|
||||
|
||||
Reference in New Issue
Block a user