What is the way to chain methods with different signatures describing a business process? #2825
-
|
Hi all, I am new in the functional programming world, so please be gentle... :D And I believe my Java knowledge is a bit rusty too. I have the following process I'd like to describe with chained methods returning The process receives a context object containing a
The What I tried is How to do this in a nice, best/good practices way? What I can think of is creating a I study functional programming in both Java and C# in the same time and the example above can be done in C# using Thanks the answers in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
I posted this to Stackoverlow. |
Beta Was this translation helpful? Give feedback.
-
|
@Andras-Csanyi Where you are using Also, .flatMap(__ -> validateInput(context.getWhateverEntityInput(), context.getCorrelationId()))I am using |
Beta Was this translation helpful? Give feedback.
-
|
If you don't want to create a bunch of classes that represent transitional stages between your methods, you could simply use a |
Beta Was this translation helpful? Give feedback.
@Andras-Csanyi Where you are using
.map(), you need to use.flatMap()(bind)..map()is for only transforming what is inside theEither.Right.Also,
.map()and.flatMap()expect a function as a parameter, so you need to do this:I am using
__here because even though.flatMap()will providecontextto its function parameter, this is not needed in this case becausecontextis already in scope from thehandle()method.