Can we Stamp Email, Recipient, AttachmentResource with no argument constructor class?
When we attempt to use these model directly on spring boot application rest endpoint, these models can't be used due to missing default constructor for jackson serialize/deserialization.
We don't want to duplicate these class attributes and transform up and down, can we make them available as usable once if you don't see any harm?
These classes are not DTO's. They are specifically designed to contain only valid state by the way they can be created through an API that is not necessarily managed through a constructor or SETTERS. Even if they currently look like a data class, I will reserve the right/freedom to change their behavior which might have side effects if treated as a DTO data class.
However, I might be able to support you by providing the dto classes you need, which can then create the proper objects from their current state as received in your endpoints. However, I can never guarantee a successful creation of the corresponding objects, as I -by design- won't be able to control the contents of those dto's (your endpoints will be obviously). So your endpoints will need to be able to handle exceptions of type EmailException to make that work.
would that satisfy your use case?
Ignore the ask bbottema, looks email has lots of attributes and they all filled safely by your builder to avoid jakarta layer failures. Again what ever you do on your builder the business layer has to do. No point in doing it.
Keep up good work!