Mapstruct - библиотека для упрощения мапинга между объектами.
implementation 'org.mapstruct:mapstruct:1.5.5.Final' annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
@Mapper(componentModel = "spring") public interface FirstObjMapper { FirstObjMapperDTO toDTO(FirstObj firstObj); }
@Autowired FirstObjMapper firstObjMapper; var foo = firstObjMapper.toDTO(firstObj);