smallrye-config icon indicating copy to clipboard operation
smallrye-config copied to clipboard

Arbitrary parameterized type as a config property?

Open mkouba opened this issue 7 years ago • 1 comments

I'm not quite sure whether this should be supported or not.

Suppose that we have a parameterized type: Foo<T>. Now I'd like to use Foo as a config property (using implicit converters), e.g.:

@Inject
@ConfigProperty(name="myFoo")
Foo<String> 

I think this wouldn't work ATM because ConfigExtension does not register a custom bean for an injetion point that has a parameterized required type: https://github.com/smallrye/smallrye-config/blob/master/implementation/src/main/java/io/smallrye/config/inject/ConfigExtension.java#L68

But it's probably a corner case...

mkouba avatar Oct 25 '18 08:10 mkouba

This could be done by allowing converter classes to be loaded with a parameter. For example it would be interesting to allow:

public class MyConverter<T> implements Converter<Foo<T>> {
    public MyConverter(Converter<T> nestedConverter) {
        ...
    }
}

or even:

public class MyConverter<T, U> implements Converter<Foo<T, U>> {
    public MyConverter(Converter<T> nestedConverter1, Converter<U> nestedConverter2) {
        ...
    }
}

Of course this adds some complexity in type resolution.

dmlloyd avatar Sep 27 '19 14:09 dmlloyd