Skip to content

What is the way to chain methods with different signatures describing a business process? #2825

Closed Answered by EarthCitizen
Andras-Csanyi asked this question in Q&A
Discussion options

You must be logged in to vote

@Andras-Csanyi Where you are using .map(), you need to use .flatMap() (bind). .map() is for only transforming what is inside the Either.Right.

Also, .map() and .flatMap() expect a function as a parameter, so you need to do this:

.flatMap(__ -> validateInput(context.getWhateverEntityInput(), context.getCorrelationId()))

I am using __ here because even though .flatMap() will provide context to its function parameter, this is not needed in this case because context is already in scope from the handle() method.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pivovarit
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants