You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 27, 2026. It is now read-only.
When it comes to implementing generics, we should consider two main issues : param transformations and type constraints.
In general, a "param transformation" is a change in the type of a parameter. There are three kinds of param transformations :
Valid param transformations : Happens on the member parameters of an Entity, after the contentValidation step. Example : Age age becomes ValidAge age.
Non-null param transformations : Happens on a nullable member parameter of a ValueObject or Entity, when it's annotated with @NullFailure. Example : Age? age becomes Age age.
Null param transformations : Happens on a nullable member parameter (which should be an InvalidModddel) of a SimpleEntity, when it's annotated with @invalidParam, after the contentValidation step. Example : InvalidAge? age becomes Null age.
Additionally, we should keep in mind that :
Member parameters of entities must be modddels
For Iterable/Iterable2 entities, the member parameter must match the TypeTemplate
Solution
With all this in mind, let's see how we can implement generics :
✅ For dependency parameters, there's no problem
✅ For member parameters that don't have any param transformation, there's no problem. These would be :
The member parameters of ValueObjects that are not annotated with @NullFailure
The member parameters of Entities that are annotated with @validParam and aren't annotated with @NullFailure
🔴 For member parameters that have a valid param transformation : The type parameter must extend BaseModddel. However, there's no way to convert the type parameter to its valid version. We can either disable the valid param transformation for type parameters, or disallow type parameters in this case.
✅ For member parameters that have a non-null param transformation : The type parameter must be non-nullable (ex : T extends Object), and the type of the member parameter must be nullable (T? param).
✅ For member parameters that have a null param transformation : The type parameter must extend InvalidModddel, and there's no restriction on whether its nullable or not as long as the resulting type of the member parameter is nullable.
Another thing to consider is how these rules apply to the types of shared properties, knowing that a SharedProp has options to disable certain param transformations.
Background
When it comes to implementing generics, we should consider two main issues : param transformations and type constraints.
In general, a "param transformation" is a change in the type of a parameter. There are three kinds of param transformations :
Age agebecomesValidAge age.@NullFailure. Example :Age? agebecomesAge age.@invalidParam, after the contentValidation step. Example :InvalidAge? agebecomesNull age.Additionally, we should keep in mind that :
Solution
With all this in mind, let's see how we can implement generics :
@NullFailure@validParamand aren't annotated with@NullFailureBaseModddel. However, there's no way to convert the type parameter to its valid version. We can either disable the valid param transformation for type parameters, or disallow type parameters in this case.T extends Object), and the type of the member parameter must be nullable (T? param).InvalidModddel, and there's no restriction on whether its nullable or not as long as the resulting type of the member parameter is nullable.Another thing to consider is how these rules apply to the types of shared properties, knowing that a
SharedProphas options to disable certain param transformations.