Below is the POJO:
public class TransferObjectListTO {
private List<A> transferList;
public List<A> getTransferList() {
return transferList;
}
public void setList(List<A> transferList) {
this.transferList= transferList;
}
public List<A> getList() {
return getTransferList();
}
public void incrementList(List<A> transferList) {
getTransferList().addAll(transferList);
}
}
It has a kind of adder method -
incrementList
along with duplicate to getter method -
getList
The Mapstruct generated code has below unnecessary stuff, which adds list, one more time of source type:
if ( targetTypeTransferObjectListTO.getList() != null ) {
List sourceTypeList = sourceTypeTransferObjectListTO.getList();
if ( sourceTypeList != null ) {
targetTypeTransferObjectListTO.getList().addAll( sourceTypeList );
}
}
We cannot remove these methods - incrementList() and getList() in above POJO because it is used in many places. Now, how can we ignore these methods when mapstruct is generating implementation for mapping?