On Wed, Dec 27, 2017 at 2:34 AM, Bojan Tomic <[email protected]> wrote: > I have a rather exotic use-case that I have to support. Types annotated with > @Id need custom deserialization logic, e.g. the value should be Base64 > decoded before deserializing it (not the only case). > > This means a type such as List<@Id Key> will be represented as a list of > Base64 Strings that I deserialize using my custom logic. > > I originally have an AnnotatedType that I convert to JavaType using > TypeFactory.constructType(annotatedType.getType()) prior to deserialization, > which of course looses all the annotations. > Later, in my custom Deserializers instance, in its various > findXXXDeserializer methods, I have no way to find the correct deserializer > as the annotations needed for the decision are gone... > > I was hoping the JDK8 module would have it's own TypeFactory-like mechanism > to construct JavaType subclasses that preserve the annotations from > AnnotatedTypes (e.g. AnnotatedTypeFactory.constructType(annotatedType)), but > it doesn't seem to be the case. > > Is there any way at all to implement what I'm after?
I think this style of annotation is new (in Java 8?), and as such there is no direct support for it at all. Annotations are preserved for accessors themselves (fields, methods, creator parameters), but not for types. There is nothing to preserve that; JavaType only contains resolved nested/generic types and is not aware of possible annotations. Support could be added in Jackson 3.0, although things could get quite complicated pretty soon. You probably access annotations in question via specific `AnnotatedMember` of `BeanProperty` (from within `createContextual`), but I have never used these types of annotations. So I think you'll be trailblazing here. -+ Tatu +- > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
