I found a lot of topics to this but all solutions went into a wrong direction in my eyes.
So... How do i use MapStruct mapping for this case?
abstract class Person:
public abstract class Person implements Serializable{
private String name;
private String somethingToIgnore
//Getter and Setter
}
The normal Mapper doesn´t work:
@Mapper(componentModel = 'cdi')
public interface PersonMapper{
@Mapping(target = 'somethingToIgnore', ignore = 'true')
Person toPerson(PersonDTO source);
@InheritInverseConfiguration
PersonDTO toPersonDtO(Person source);
}
I am not allowed to map an abstract class. I should use the a factory method. I tried but i simply have no clue how this factoy method should look like...
My attempt:
@Mapper
public interface PersonMapper {
PersonMapper INSTANCE = Mappers.getMapper( PersonMapper.class );
Person toPerson(PersonDTO source);
PersonDTO toPersonDtO(Person source);
}
@Mapper
public abstract class PersonMapper {
public static final PersonMapper INSTANCE = Mappers.getMapper( PersonMapper.class );
Person toPerson(PersonDTO source);
PersonDTO toPersonDtO(Person source);
}
What am i missing and doing wrong ? Thanks in advance.