And I see that there's a getTypeContext() method replaced the old
getContextClass
in this commit
<https://github.com/FasterXML/jackson-databind/commit/0e4249a2b6cd4ce71a2980b50dcd9765ad03324c#diff-4f2f19b7140280e7d47b48e1d0df1139L75>
but
I don't know how to make use of it to achieve my goal.
On Tuesday, August 15, 2017 at 5:39:32 PM UTC-7, Jama A wrote:
>
> Sorry about the bad explanation, so here's the small part of my custom
> AnnotationInspector.
>
>
> public class DocumentAnnotationIntrospector extends NopAnnotationIntrospector
> {
>
> @Override
> public Object findInjectableValueId( AnnotatedMember annotatedMember ) {
> // let's say, annotationMember value is BaseFoo#version and I want to
> get the actual class (Bar) of that object not the parent (BaseFoo)
> Class<?> declaringClass = annotatedMember.getDeclaringClass(); // here
> it returns parent class not the sub-class(Bar) that type of object.
>
> // but before I used to have *annotatedMember.**getContextClass() *- I
> have a custom logic that preprocesses and injects a value in here based on
> the subclass.
>
> return null;
> }
> }
>
>
>
> When deserializing the Bar object (from above example) - all annotated
> fields go through the `findInjectableValueId ()` method of my custom
> annotation inspector. And in v2.5, there're used to be
> annotatedMember.getContextClass(); which used to return Bar class for
> the fields that declared in the parent class. But now I don't have that
> method in 2.8, but the only option I see is that
> annotatedMember.getDeclaringClass() which returns BaseFoo class
>
> Please let me know if more clarification is needed.
>
> Thanks!!
>
> On Tuesday, August 15, 2017 at 5:03:53 PM UTC-7, Tatu Saloranta wrote:
>>
>> On Tue, Aug 15, 2017 at 4:10 PM, Jama A <[email protected]> wrote:
>> > I used
>> >
>> `com.fasterxml.jackson.databind.introspect.AnnotatedMember#getContextClass`
>> > in my project to get actual sub-class name that field has a value. But
>> it
>> > was removed in this commit [Starting work on ensuring proper resolution
>> of
>> > member types;......]
>> > But now I can't find a context class, consider this example.
>> >
>> > abstract class BaseFoo {
>> > private String id;
>> > private Long version;
>> >
>> >
>> > /// getters/setters
>> >
>> >
>> > }
>> >
>> > class Bar extends BaseFoo{
>> > //some other fields
>> >
>> > }
>> >
>> >
>> > In my custom AnnotationIntrospector I need to find the actual sub-class
>> > (Bar) from the AnnotatedMember object. I see there's only
>> > AnnotatedMember#getDeclaringClass() which returns the class that
>> physically
>> > declared (BaseFoo)
>> >
>> > But I can't make use of it - how can I find actual sub-class that
>> annotated
>> > member field is associated?
>>
>> Unfortunately I don't think I fully understand the use case from this.
>> Could you share example code from your custom AnnotationIntrospector
>> method to help understand what information you are looking to get?
>>
>> -+ 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.