Open chrylis opened 2 years ago
i don't understand, where would you pass the supplier? we can't change the annotation to use a supplier instead of a class, because annotations don't support that.
If it helps, you can already provide your own HandlerInstantiator, which you can use to hook into the creation logic of the resolvers.
There are a number of places across Jackson where no-arg constructors are required, such as for
TypeIdResolver
s. I have some use cases involving both partitioned type names (separate JSON:API "APIs", where type names are namespaced) and dynamic type resolution where it would be helpful to be able to parameterize theTypeIdResolver
used in particular cases.In addition, inside my implementation of
TypeIdResolver
I would like to be able to capture the information I'm using to resolve the type and insert it into the instance of the data class that's produced byreadValue
.For Jackson 3, I would like to be able to pass a
Supplier<TypeIdResolver>
instead of specifying aClass<? extends TypeIdResolver>
that must have a no-arg constructor; similarly, instead of returningJavaType
fromtypeFromId
, I would like to be able to return aSupplier<T>
, so that I can do something like:If done as a consistent global refactor, supporting the no-arg constructor case is still simple (
Bar::new
), but extending Jackson would be both easier and probably cleaner.