Hullaballoonatic
11/18/2019, 5:43 PM@Bean
fun springClassInstance() = SpringClass().apply {
setA(a)
setB(b)
setC(c)
}
this syntax just makes me cry. it's a shame there can't be more constructor variants or at the very least builders for some of these classes...
it would be so much nicer to just be
@Bean fun springClassInstance() = SpringClass(a = a, b = b, c = c)
but you know.... java things.
nvm me, complaining to the etherHullaballoonatic
11/18/2019, 5:47 PMobject SpringClass {
operator fun invoke(a: A, b: B, c: C) = SpringClass().apply {
setA(a)
setB(b)
setC(c)
}
}
but the confusion of importing this object instead of the actual class sacrifices all the readability that such syntax would offer, i thinkThiago Nerys
11/18/2019, 5:49 PM@Bean
fun springClassInstance() = SpringClass().apply {
a = a
b = b
c = c
}
This notation is very simmilar to the one with constructorHullaballoonatic
11/18/2019, 5:52 PMa = a
does not compile and you have to use setA(a)
Marko Mitic
11/18/2019, 5:58 PMMarko Mitic
11/18/2019, 5:59 PMvoid setA(A a)
method in java, you should be able to call if with obj.a = someA
Hullaballoonatic
11/18/2019, 6:53 PMHullaballoonatic
11/18/2019, 6:56 PM