This seems like a terrible way to architect an application. No longer do we have a simple Customer data class, but a hybrid monstrosity that grows every time a new use case involving a nullable field is introduced.
I would much rather prefer to have a use-case specific class that takes care of notifying a Customer of something, and a @Nullable annotation on the Customer fields that can be null. Then:
- Every use case can decide how it wants to handle those situations, and express it in a clear way
- Every use case can be modified or deleted independently without having to do surgery in some huge object
- The code is clearly readable without having to jump through levels of indirection and polymorphism to get to the actual logic
I would much rather prefer to have a use-case specific class that takes care of notifying a Customer of something, and a @Nullable annotation on the Customer fields that can be null. Then:
- Every use case can decide how it wants to handle those situations, and express it in a clear way
- Every use case can be modified or deleted independently without having to do surgery in some huge object
- The code is clearly readable without having to jump through levels of indirection and polymorphism to get to the actual logic