mapstruct: reuse mapper configuration is ignored

18 views Asked by At

I'm trying to re-use an already defined Mapper on another one.

@Mapper
public interface ReferenceUniqueIdentifierMapper {
        //...
    default String toPersistenceModel(ReferenceUniqueIdentifier id) {
        return id.getId().toString();
    }
}

In another Mapper, I'm trying to re-use previous defined mapper:

@Mapper(uses = ReferenceUniqueIdentifierMapper.class)
public interface NestedReferenceMapper {

        //...

    @Mapping(source = "referenceUniqueIdentifier", target = ".")
    String toPersistenceModel(NestedReference persistence);

Nestedrefference is like:

public class NestedReference {

    private final ReferenceUniqueIdentifier referenceUniqueIdentifier;
        //...
}

So, I'm trying to map NestedReference.referenceUniqueIdentifier to String using ReferenceUniqueIdentifier.toPersistenceModel(ReferenceUniqueIdentifier id) .

Generated code is:

    @Override
    public String toPersistenceModel(NestedReference persistence) {
        if ( persistence == null ) {
            return null;
        }

        String string = new String();

        return string;
    }

Any ideas about how to peak ReferenceUniqueIdentifierMapper.toPersistenceModel from NestedReferenceMapper?

0

There are 0 answers