我有一个像这样的对象:
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;
}
}
- 当然它也有一个空的ctor、hashcode和equals。
我想深拷贝这个对象。
我为此使用了推土机。像:
DozerBeanMapper beanMapper = new DozerBeanMapper();
Elem dst = beanMapper.map(src, Elem.class)
但是我收到一个错误:
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)
有人可以解释为什么推土机在列表列表方面有问题,也许我该如何解决这个问题?