Stephan Schroeder
05/02/2019, 2:23 PM<T> T getBean(String name, Class<T> requiredType) throws BeansException;
Object getBean(String name, Object... args) throws BeansException;
I want to call the former, but Kotlin calls the later and then flags my implementation as not guaranteeing the specified type
fun worker(worker: String): PipelineElementProcessor = try {
context.getBean(worker, PipelineElementProcessor::javaClass)
}
Is there as solution apart from casting the result to PipelineElementProcessor?ribesg
05/02/2019, 2:27 PMcontext.getBean<PipelineElementProcessor>(worker, PipelineElementProcessor::javaClass)
Lawik
05/02/2019, 2:27 PMStephan Schroeder
05/02/2019, 2:36 PMcontext.getBean(worker) as PipelineElementProcessor
but am still open to suggestions.Lawik
05/02/2019, 2:42 PMobobo
05/02/2019, 2:46 PMgetBean
has a parameterized type, would calling it as context.getBean<PipelineElementProcessor>(...)
work?Stephan Schroeder
05/02/2019, 2:47 PMobobo
05/02/2019, 2:48 PMStephan Schroeder
05/02/2019, 2:49 PMobobo
05/02/2019, 2:55 PMPipelineElementProcessor::class.java
::javaClass
::javaClass
I had the same problem you did.javaClass
shouldn't be invoked by reference, but instead on an instance of a class, since it uses the receiver to determine the type parameter.Stephan Schroeder
05/02/2019, 3:05 PMcontext.getBean(worker, PipelineElementProcessor::class.java)
works 😃