Код: Выделить всё
public abstract class MyAbstractB {
private B b;
}
public abstract class MyAbstractBDto {
private BDto bDto;
}
public class ItemWithB extends MyAbstractB {
private C c;
}
public class ItemWithBDto extends MyAbstractBDto {
private CDto cDto
}
Код: Выделить всё
@Mapper
public abstract class BMapper {
@Autowired Converter converter;
public abstract BDto map(B b);
@AfterMapping
public void convert(B src, @MappingTarget BDto dest) {
converter.convert(src,dest);
}
}
@Mapper(uses = BMapper.class)
public abstract class MyAbstractMapper {
}
@Mapper(uses = MyAbstractMapper.class)
public abstract class ItemWithBMapper {
BDto map(B b);
}
Код: Выделить всё
@Component
public class ItemWithBMapperImpl extends ItemWithBMapper {
@Autowired BMapper bMapper;
@Override
public ItemWithBDto map(ItemWithB itemWithB) {
ItemWithBDto itemWithBDto = new ItemWithBDto();
itemWithBDto.setBDto( bMapper.map(itemWithB.getB()));
}
}
Код: Выделить всё
@Component
public class ItemWithBMapperImpl extends ItemWithBMapper {
@Override
public ItemWithBDto map(ItemWithB itemWithB) {
ItemWithBDto itemWithBDto = new ItemWithBDto();
itemWithBDto.setBDto( localmapper(itemWithB.getB()));
}
public BDto bDtomapper(B b) {
// copies fields from b to BDto
}
}
Если я изменю ItemWithBMapper на:
Код: Выделить всё
@Mapper(uses = BMapper.class)
public abstract class ItemWithBMapper {
BDto map(B b);
}
Я неправильно понимаю, как работает/наследуется «использование»? Или я что-то не так сделал?
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/798 ... herit-uses
Мобильная версия