I have following structures
Public void Student(){
private string name;
private int age;
}
Public void Class(){
private string roomNo;
private Student student; //Student Object
}
Public void School(){
private string roomNo;
private String student; //String student
}
I am trying to map these using map struct
@Mapping(source = "java(student.toString())", target = "student")
School mapClassToSchool(@NonNull Class class);
I am getting following error
error: No property named "java(student.toString())" exists in source parameter(s). Did you mean "student"?
[javac] @Mapping(source = "java(student.toString())", target = "student")
[javac] ^
I tried to go through this https://mapstruct.org/documentation/stable/reference/html/ but cant simple example for my usecase
Ho do i map student to its string representation
Edit: 1
is it possible to do
@Mapping(expression = new GSON().toJson(clazz.getStudent()), target = "student")
School mapClassToSchool(@NonNull Class class);