Skip to content

Instantly share code, notes, and snippets.

@maarek
Created May 18, 2017 03:02
Show Gist options
  • Save maarek/44104fab9aa0a35a4438cfb7b6fbea6e to your computer and use it in GitHub Desktop.
Save maarek/44104fab9aa0a35a4438cfb7b6fbea6e to your computer and use it in GitHub Desktop.
// How to do this functional flow in Javaslang/Vavr
Response response = new PersonValidator().validatePerson("First", "Last"); // Returns Validation<Seq<String>, Person>
// success -> Try.of(() -> sendToMoon(Person)) // Throws Exception or returns void
// trySuccess -> Response.ok().build()
// tryFailure -> Response.Status(BadRequest).entity(throwable).build()
// failure -> Response.Status(BAD_REQUEST).entity(validatorStringsAppended).build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment