Let'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
/InvalidModddel
andBaseModddel
, and also no association betweenValidValueObject
/InvalidValueObject
andValueObject
. That's on purpose because those interfaces can be directly implemented in some cases, and we don't want theBaseModddel
methods to be inherited. (See the models that are always valid / invalid section).