Skip to content
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

Use @JsonCreator with vavr validation? #128

Open
smarijic opened this issue Dec 24, 2018 · 3 comments
Open

Use @JsonCreator with vavr validation? #128

smarijic opened this issue Dec 24, 2018 · 3 comments

Comments

@smarijic
Copy link

Hi,

Is there a way to return Try from static factory annotated with @JsonCreator?
Here is question on SO. https://stackoverflow.com/questions/53917859/jackson-jsoncreator-return-generics

Thanks.

@mincong-h
Copy link
Member

mincong-h commented Aug 11, 2019

I think this is not supported by Vavr Jackson yet. Returning Try<T> instead of T requires new serializer and deserializer. The deserializer will be able to modify the existing type T and encapsulate it into Try<T>, in both success and failure cases. However, this is a completely new feature. What do you think, @ruslansennov and @danieldietrich ?

I believe a simplified version of @smarijic 's request is:

Try<FooCommand> cmd = mapper.readValue(json, new TypeReference<Try<FooCommand>>() {});

@ruslansennov
Copy link
Member

Looks like Option, and can be implemented in the same ugly way. But I believe that these new serializer and deserializer have more rights to life than mutable Iterator (see #130)

@mincong-h
Copy link
Member

Thank you, @ruslansennov . Could you give some additional hints about the changes to make? I didn't fully understand the exception shown at issue 130. I'll take a look in the coming days and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants