java - How to pass `this` to Dozer field mapping? -
in app have dozer mapping looks this:
<mapping> <class-a>java.util.hashmap</class-a> <class-b>org.mycompany.targetclass</class-b> <field custom-converter="org.example.myconverter"> <a>this</a> <b>anotherfield</b> </field> </mapping>
myconverter
instance of configurablecustomconverter
:
public class myconverter implements configurablecustomconverter { private string parameter; @override public object convert( object existingdestinationfieldvalue, object sourcefieldvalue, class<?> destinationclass, class<?> sourceclass) { // sourceclass java.lang.object , // sourcefieldvalue null!!! } @override public void setparameter(string parameter) { this.parameter = parameter; } }
why things noted in in-source comment happen?
you need tell dozer key of map should mapped b.anotherfield
, like
<field custom-converter="org.example.myconverter"> <a key="foobar">this</a> <b>anotherfield</b> </field>
Comments
Post a Comment