对象不是使用集合在深度推土机映射上声明类的实例

时间:2017-03-02 18:48:12

标签: java dozer

我正在尝试通过dozer深度映射两个类型为set的属性。我的示例代码如下,

class SomeObject {
    String name;
}

class AnotherObject {
    String myName;
}

class A {
    private String identity;
    private Set < SomeObject > someSet  = new HashSet < SomeObject >;
}

class B {
    private String id;
    private Set < AnotherObject > someAnotherSet = new HashSet < AnotherObject >;
}

下面是我尝试通过dozer API进行深度映射的代码

BeanMappingBuilder builder = new  BeanMappingBuilder () {
    mapping(A.class, B.class)
        .fields("identity", "id")
        .fields("someSet.name", "someAnotherSet.myName");
}

在运行上面的示例时,我发现以下错误

java.lang.IllegalArgumentException: object is not an instance of declaring class

任何帮助将不胜感激。感谢

0 个答案:

没有答案