-
Notifications
You must be signed in to change notification settings - Fork 166
CloudEventUtils.mapData(event, mapper) #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added toData(CloudEventDataMapper) method to map the data Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
|
As it was debated many times before this change violates the consistency and simplicity of the core interface. Tagging @n3wscott @duglin as I already have an open complaint about a PR being merged with no consensus reached - #250 (comment) |
|
Related to #258 |
|
My feeling is that serialization/conversion should not be a part of the interface, it's a separate concern. It would be OK if it was an extension function provided by the serialization library/module. |
|
@johanhaleby Except we don't have extensions in java 😄 How about moving to some utils class, like |
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
|
Moved, now it should be better |
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
core/src/main/java/io/cloudevents/core/message/MessageReader.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/cloudevents/core/message/StructuredMessageReader.java
Outdated
Show resolved
Hide resolved
|
This seems like the next natural step after the previous improvements. /lgtm |
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
pierDipi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR adds a new method to
CloudEventUtils, calledmapData(event, mapper)(implemented by default), to improve the user experience with mappers. Now we finally have a good user experience for data: users can now safely map event payloads to business objects without casting and without any knowledge of the sdk itself:(note: this example is using json mapper which is proposed in another pr independent from this one)
To make this possible, I also generified the return value of CloudEventDataMapper
Signed-off-by: Francesco Guardiani francescoguard@gmail.com