Home > Mobile >  MapStruct: Unknown property when map inherited objects
MapStruct: Unknown property when map inherited objects

Time:10-23

I have this error Unknown property "addUsrIdentif" in type NonExistentClass for target name "addUsrIdentif.userId". Did you mean "null"? when i tried to map like below

public class ConfirmPayerRq extends AbstractMessageRq {
    protected String phoneNumber;
}

public abstract class AbstractMessageRq extends AbstractMessage{
    protected AddUsrIdentif addUsrIdentif;
}

@Mapping(source = "userId", target = "addUsrIdentif.userId")
fun confirmPayerAgentRequestToConfirmPayerRq(source: ConfirmPayerAgentRequest): ConfirmPayerRq

CodePudding user response:

This might help ,sample :-

public class Operation {

    public static void main(String[] args) {
        System.out.println(Integer.toHexString(-10));
    }
}

CodePudding user response:

You should declare the fields as public or define public getters. Referring to Filip's answer:

Currently MapStruct only support mapping from public fields / properties. There is an open Feature Request requesting functionality for package private / protected attributes.

  • Related