Как сопоставить массив объектов, в частности первый элемент (array[0]), из одного класса в другой с помощью MapStruct. В настоящее время появляется ошибка типа «люди[0] не в свойстве источника, вы имели в виду людей».
public class Source {
private Person[] people;
// Getter and Setter
}
// Destination class
public class Destination {
private Person person;
// Getter and Setter
}
// Person class (assuming it's a separate class)
public class Person {
private String name;
// Getter and Setter
}
// Mapper interface
@Mapper
public interface MyMapper {
MyMapper INSTANCE = Mappers.getMapper(MyMapper.class);
@Mapping(source = "people[0]", target = "person")
Destination mapToDestination(Source source);`
}
Подробнее здесь: https://stackoverflow.com/questions/776 ... mapstructs
Мобильная версия