convertersquarkus

Using Config Converter for converting Map values


In quarkus extension, I've a configuration like the following that is mapping properties to a Java map and I'm trying to convert Map values with a custom converter.

` @ConfigMapping(prefix = "my.prefix")

public interface MyConfig {

@WithConverter(FunctionConverter.class)
Map<String, Function> functions();

} `

This fails at build time with error:

java: java.lang.ClassCastException: class com.sun.tools.javac.code.Type$ArrayType cannot be cast to class javax.lang.model.type.DeclaredType (com.sun.tools.javac.code.Type$ArrayType is in module jdk.compiler of loader 'app'; javax.lang.model.type.DeclaredType is in module java.compiler of loader 'platform')

Is there a way I can achieve the desired behaviour?


Solution

  • Use the following definition instead:

    Map<String,  @WithConverter(FunctionConverter.class) Function> functions();