jmapper-framework / jmapper-core

Elegance, high performance and robustness all in one java bean mapper
http://jmapper-framework.github.io/jmapper-core
Apache License 2.0
227 stars 41 forks source link

Mapping a flat source to a nested destination not working #89

Open rajalingams opened 4 years ago

rajalingams commented 4 years ago

I am trying to convert the flat source to the nested destination structure using a single jmapper instance with an xml configuration.

My source class:

class Source {
    String name;
    Integer age;
    String city;
}

My destination classes:

class Destination {
    String fullName;
    PersonalInfo personalInfo;
}
class PersonalInfo {
    Integer age;
    String location;
}

XML configuration:

<jmapper>
    <class name="Destination">
        <attribute name="fullName">
            <value name="name"/>
        </attribute>
        <attribute name="personalInfo">
            <value name="${}"/>
        </attribute>
    </class>
    <class name="PersonalInfo">
        <attribute name="age">
            <value name="age"/>
        </attribute>
        <attribute name="location">
            <value name="city"/>
        </attribute>
    </class>
</jmapper>

"${}" is not working. I know that it works if the source also has an encapsulated class and it can be passed in. Is there a way to pass the original instance as a whole to personalInfo?