Hi,
I have an existing heirarchy of classes, say something like this:
Business
- Division
- ProjectTeam
- Employee
These classes are instantiated via deserialization.
However, now I need to expose extra fields in the Employee for a particular user of the library i.e. say something like this:
SpecialBusiness (extends Business)
- Division
- ProjectTeam
- SpecialEmployee (extends Employee)
- Degree
The problem is, I can't just make a class that extends 'Business' because the addition I want to make is to the 'Employee' class.
As I see it I have two options:
Duplicate the heirarchy with 'Special' classes. This means each 'Special' class will have a collection of the original classes and a collection of the new 'Special' classes.
SpecialBusiness - Division AND SpecialDivision (extends Division) - ProjectTeam AND SpecialProjectTeam (extends ProjectTeam) - Employee AND SpecialEmployee (extends Employee) - Degree
Somehow retype 'Employee' to 'SpecialEmployee' at runtime for deserialization purposes. Know that I can cast all 'Employee' objects from a SpecialBusiness to 'SpecialEmployee' in the codebase (possibly using helper methods to make it obvious).
Any ideas on how to deal with this problem?