有三个类
class DeviceFormatA {
private Integer id;
private String name;
private Integer type;
}
class DeviceFormatB {
private Integer id;
private String name;
private Type type;
}
class Type {
private Integer id;
private String name;
}
我从远程服务器上获取数据根据返回json格式自动封装成DeviceFormatB
类型,现在我需要取出其中的type.id,然后将DeviceFormatB
转换为DeviceFormatA
对象存到本地数据库,请问将DeviceFormatB转换为DeviceFormatA,应该怎样做效率比较高,如果新建一个DeviceFormatA,再全部重新~~~~赋值是不是太繁琐了。
bean copy框架的优点和缺点都很明显:
优点
缺点