如何解决MapStruct为生成实现Iterable <T>接口的对象生成文件
class Curve implements Iterable<Point> {
protected String curveName;
protected Date curveVersion;
protected String curveType;
protected List<Point> points;
<!--- public getter&setters --->
}
class Point {
protected int x;
protected int y;
protected int z;
<!--- public getter&setters --->
}
当我为Curve类创建一个映射器抽象类/接口时,如下所示:
public abstract class CurveMapper {
CurveMapper INSTANCE = Mappers.getMapper(CurveMapper.class);
protected abstract com.entity.Curve map(com.dto.Curve);
}
自动生成的CurveMapperImpl类仅为Iterable中的Point类字段创建映射。除点字段外,Curve类(子类)的所有字段都将被忽略。
例如:
public class CurveMapperImpl implements CurveMapper {
@Override
public com.entity.Curve map(com.dto.Curve arg0) {
if (arg0 = bull)
return null;
com.entity.Curve curve1 = new com.entity.Curve();
for (com.dto.Point point : curve.getPoint()) {
curve1.add(covertPoint(point));
}
}
protected com.entity.Point convertPoint(com.dto.Point point) {
com.entity.Point point1 = new com.entity.Point();
point1.setX(point.getX);
point1.setY(point.getY);
point1.setZ(point.getZ);
return point1;
}
所有文件,例如 curveName
, curveVersion
, curveType
,均未映射。即使在尝试对带有源和目标的 @Mapping
批注后,该批注也不起作用。但是,如果我删除实施 Iterable<Point>
,它将起作用。我无法修改对象类,因为它们来自库。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。