#15 MappingProcessor to use multiple hints from DestHintContaine

Dozer v.4.3
closed-accepted
None
5
2008-11-25
2008-04-10
No

A single-line patch to make MappingProcessor use multiple hints for destination classes during mapping of fields. It changes the behaviour of MappingProcessor only if both source and dest. hints are specified AND both are comma-separated lists (as described in the HintContainer).

This was needed when we wanted to map between a hierarchy of classes occurring as field types.
In short words:

Imagine a class A (will be mapped to APrime) with field "x" of type "X" (mapped to "x" of type "XPrime"). And now X type is abstract having several concrete subclasses (X1,X2,X3). The same hierarchy on the "right-hand-side" (XPrime having subclasses: X1Prime, X2Prime, X3Prime).
Let's say we want to map an instance of class A to APrime without knowing the very detail runtime type of x field value.

The solution is to have the mapping as follows:
<mapping>
<class-a>package.A</class-a>
<class-b>package.APrime</class-b>
<field>
<a>x</a>
<b>x</b>
<a-hint>package.X1,package.X2,package.X3</a-hint>
<b-hint>package.X1Prime,package.X2Prime,package.X3Prime</b-hint>
</field>
</mapping>

and run it like this:
mapper.map(new A(new X2(5L)), APrime.class);

Without this patch it doesn't work. Patching fixes the problem.

Discussion

  • ed

    ed - 2008-11-25

    Used it and it works well.
    I get more the feeling that itsn't a undocumented feature that wasn't unsed correctly.

     
  • GrzegorzOledzki

    GrzegorzOledzki - 2008-11-25

    Not quite sure if I understand you.
    You think it was a undocumented feature (with a bug within), right?

    (If so, I can nothing but agree)

     
  • ed

    ed - 2008-11-25

    Yep (wrote it wrong).

     
  • dmitry (lv)

    dmitry (lv) - 2008-11-25
    • milestone: --> Dozer v.4.3
    • assigned_to: nobody --> buzdin
    • status: open --> closed-accepted
     
  • ed

    ed - 2008-11-25

    Go Dimitri ... go Dimitri .... :)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks