简体   繁体   中英

Mapping a Object map property to Map using Dozer

How Can I map a map object property values to map using dozer.

Here is my class :

public class SimplePojo {
private String field1;
private String field2;
private Map<String, String> attributes = new HashMap<String, String>();

public String getField1() {
    return field1;
}

public void setField1(String field1) {
    this.field1 = field1;
}

public String getField2() {
    return field1;
}

public void setField2(String field2) {
    this.field2 = field2;
}

public Map<String, String> getAttributes() {
    return attributes;
}

public void setAttributes(Map<String, String> attributes) {
    this.attributes = attributes;
}

}

attributes map is having some Key-Value pairs like <key1-value1> etc. This data should go with object properties as key-value pair to the resulting map.

How can I do this mapping?

Personally I haven't tried this but the dozer documentation has the details, have you tried this?

http://dozer.sourceforge.net/documentation/mapbackedproperty.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM