getters with different type not mapping.

86 views
Skip to first unread message

Baron MG

unread,
Mar 25, 2021, 5:01:54 PM3/25/21
to mapstruct-users
hi guys,

mapstruct cannot seem to find method annotated with @Named unwrap

@Data //domain
public class Address {
    private Address address;

//getter method
public <Address> getAddress();
}


@Data //entity
public class Address {
    private Address address;

//getter method
public Address getAddress();
}

public class Person{
Adress address;
}


@Component
@Mapper(componentModel = "spring", uses = AddressMapper.class,
injectionStrategy = InjectionStrategy.CONSTRUCTOR)
public interface PersonMapper {

    @Mappings({@Mapping(target = "address", source= "address", qualifiedByName = "unwrap")})
    Person toPerson(final PersonDto domain);


@Named("unwarp")
default <T> T unwrap(Optional<T> optional) {
return optional.orElse(null);
}

Please, help.
Reply all
Reply to author
Forward
0 new messages