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> 

see http://dozer.sourceforge.net/documentation/mapbackedproperty.html#mapping_class_level_properties_to_a_java.util.map_or_a_custom_map_with_unique_getset_methods


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -