-
Notifications
You must be signed in to change notification settings - Fork 168
Description
[info/enhancement proposal] Here's a quick idea to avoid repetitively writing extensions.
The limitations of this concept, to be safe from many perspectives, are that the supported types are basic, and therefore complex elements must be handled outside of the extension itself.
However, there are several advantages, including having ordered keys, working with inheritance, simplifying extension development, and the ability to type both getters and withers. So at the end, we have a patternization of extension creation.
The following link contains the code to implement this concept: https://gist.github.com/stefanofago73/dd03952e9a2c5f2f113ea064320785d0
Could this be helpful? Could it work, or is it not useful due to other use cases or parts of the library?
The basic design is to have a base class and create Extensions by inheritance. The constructor allows you to register keys, while the extension itself allows you to create typed withers. The Java CloudEvents SDK methods are implemented in the base class, including the hashCode and equality methods. The example code is commented and includes an example of an extension (auth context extension).