Closed esfomeado closed 1 year ago
@esfomeado
Hi, you can use FailoverArbitraryIntrospector
. It is the one exactly what you want.
Details here
Not sure how I missed that one. That's it thanks.
@seongahjo After looking at the FailoverArbitraryIntrospector
it doesn't work as expected.
If the class can be generated with both Introspectors it will combine the result which isn´t want I want.
I was expecting the following:
If the class was generated via one introspector return right away otherwise keep trying until it generates.
I will implement this Introspector on my project but I think its's useful to have it by default as well on the lib.
@esfomeado
If the class can be generated with both Introspectors it will combine the result which isn´t want I want.
Is there a test case that can be reproduced?
FailoverArbitraryIntrospector
should be generate by only one ArbitraryIntrospector.
Describe the feature you request
As of now it's possible to call multiple Arbitary Introspectors by using the
CompositiveArbitaryIntrospector
. This will call all introspectors but for my use case I would like to define multiple introspectors similar to theCompositiveArbitaryIntrospector
but only call the introspectors until the object is created and then stop.Example:
CompositiveArbitaryIntrospector( List.of( ConstructorPropertiesArbitaryResolver.INSTANCE, FieldReflectionArbitaryIntrospector.INSTANCE ) )
.Class A - Can only be generated via constructor. So it uses the
ConstructorPropertiesArbitaryResolver
and it stops. Class B - Can only be generated via reflection. Tries to generate via theConstructorPropertiesArbitaryResolver
fails and goes to the next oneFieldReflectionArbitaryIntrospector
. The class is generated and then stopsAs workaround I have to defined an
objectIntrospector
and then define per class another one in case it´s different from the default one. Example:objectIntrospector(ConstructorPropertiesArbitaryResolver.INSTANCE) .pushExactTypeArbitaryIntrospector(ClassB.class, FieldReflectionArbitaryIntrospector.INSTANCE