Preparation
Always make sure to pull/clone/download the latest 101simplejava repo.
See the instructions here:
https://github.com/101companies/101simplejava/blob/master/README.md
Starting point
Both of these contributions:
- http://101companies.org/wiki/Contribution:javaInheritance (Simple Java object model using inheritance)
- http://101companies.org/wiki/Contribution:jaxbComposition (XML Schema-derived object model using object composition)
You are sort of supposed to merge these two contributions into one.
Task
You tackle the problem of a mapping between different object models. Let's assume the preferred object model in your development team is the one of Contribution:javaInheritance. Let's further assume that your development team is required to marshall and unmarshall objects according to Contribution:jaxbComposition. Thus, a mapping is needed as follows:
- There is a (static) method compositionToInheritance to map companies according to Contribution:jaxbComposition to companies according to Contribution:javaInheritance.
- There is a (static) method inheritanceToComposition to map companies the other way around.
Hints
The object models are quite similar. The key difference is that one uses object composition for aggregating employees and departments where the other one uses inheritance to model types for employees and departments as subtypes of a general type for subunits. The mapping methods need to traverse over objects of one kind and construct objects of the other kind. Fully qualified names may need to be used in the mapping code since both object models share some names such as Company, Department, and Employee. You may need to change some package name because both initial object models use the same package.
For simplicity, please also submit the Java code for the schema-derived object model. Thus, no build rules for the object model need to be submitted.
Testing
You basically need to cherry pick from the test cases of the Contribution:jaxbComposition and Contribution:javaInheritance such that the sample company should be unmarshalled indeed from XML and then mapped from Contribution:jaxbComposition to Contribution:javaInheritance to carry out standard test cases for totaling and cutting salaries. (Only one direction of mapping may be exercised this way; that's Ok.)