If you look at the diagram you will see that Employee and Person have descendants, LinearManager and DetailedPerson respectively. Do we need to repeat mapping rules for Employee and Person in a mapping for LinearManager and DetailedPerson? Of course, no! All we need to describe specific mapping rules as shown in the next snippet.
// detailedPerson2LinearManager.groovy mappingFor a: DetailedPerson, b: LinearManager a.description = b.characteristics a.educationName = b.details.educations[0].name a.educationDescription = b.details.educations[0].description
Then we have to parse the both mappings as follows.
NominMapper nomin = new Nomin("person2employee.groovy", "detailedPerson2LinearManager.groovy"); DetailedPerson dp = new DetailedPerson(); // create and initialize a DetailedPerson instance LinearManager lm = nomin.map(dp, LinearManager);
Firstly Nomin searches all applicable mappings between classes DetailedPerson and LinearManager. The first of them is mapping between Person and Employee because these classes are lower in the hierarchies, the second is one between DetailedPerson and LinearManager. Nomin applies these mapping one by one. You can use this Nomin's behaviour to overwrite mapping rules.