@Target(value=PARAMETER) @Retention(value=CLASS) public @interface MappingTarget
Not more than one parameter can be declared as MappingTarget
.
NOTE: The parameter passed as a mapping target must not be null
.
Example 1: Update exist bean without return value
@Mapper
public interface HumanMapper {
void updateHuman(HumanDto humanDto, @MappingTarget Human human);
}
// generates
@Override
public void updateHuman(HumanDto humanDto, Human human) {
human.setName( humanDto.getName() );
// ...
}
Example 2: Update exist bean and return it
@Mapper
public interface HumanMapper {
Human updateHuman(HumanDto humanDto, @MappingTarget Human human);
}
// generates:
@Override
public Human updateHuman(HumanDto humanDto, Human human) {
// ...
human.setName( humanDto.getName() );
return human;
}
Copyright © 2012-2021 MapStruct Authors; All rights reserved. Released under the Apache Software License 2.0.