Class Hierarchy of ValueObjects

I: The type of the generated invalid modddel - V: The type of the generated valid modddelLet's say you want to create an Age ValueObject. Age will either extend SingleValueObject or MultiValueObject. Both are subclasses of ValueObject, which is a subclass of BaseModddel (the base class of all modddels).
ValidAge, which extends Age, will implement ValidValueObject, which implements ValidModddel.
InvalidAge, which extends Age, will implement InvalidValueObject, which implements InvalidModddel.
NB 1 : The generated classes (
Age,InvalidAge...) will define other properties and methods than the ones already defined by the superclasses. (Ex:map,maybeMap,copyWith... and all the others)NB 2 : Notice how there is no association between
ValidModddel/InvalidModddelandBaseModddel, and also no association betweenValidValueObject/InvalidValueObjectandValueObject. That's on purpose because those interfaces can be directly implemented in some cases, and we don't want theBaseModddelmethods to be inherited. (See the models that are always valid / invalid section).