i have an Object like this:
public class Elem
{
private List<List<String>> elements;
public List<List<String>> getElements()
{
return elements;
}
public void setElements(List<List<String>> elements)
{
this.elements = elements;
}
}
- of course it has also an empty ctor, hashcode and equals.
i would like to deep copy this object.
i used dozer for that. like:
DozerBeanMapper beanMapper = new DozerBeanMapper();
Elem dst = beanMapper.map(src, Elem.class)
however i get an error:
java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.dozer.util.ReflectionUtils.determineGenericsType(ReflectionUtils.java:364)
at org.dozer.util.ReflectionUtils.determineGenericsType(ReflectionUtils.java:352)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.genericType(GetterSetterPropertyDescriptor.java:335)
at org.dozer.fieldmap.FieldMap.getGenericType(FieldMap.java:145)
at org.dozer.MappingProcessor.mapCollection(MappingProcessor.java:493)
at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:422)
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:330)
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:276)
at org.dozer.MappingProcessor.map(MappingProcessor.java:245)
at org.dozer.MappingProcessor.map(MappingProcessor.java:187)
at org.dozer.MappingProcessor.map(MappingProcessor.java:124)
at org.dozer.MappingProcessor.map(MappingProcessor.java:119)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:111)
Can someone please explain why Dozer have problems with list of lists and maybe how can i sort this out?
as @artbristol commented, this indeed is an issue in sourceforge dozer. i looked this issue in github dozer, althouge it is not listed in the issues it is not working there as well.
currently my fix is to set this field to null before mapping, then map this field by my self and set both variables with the corresponding fields.
i will open an issue for that on the github project and will try to contribute a fix.