I want to create two Ticket objects for two Seat objects. In uri string, chars 2 and 3 are primary keys for seats.
The idea is to use Java streams to perform splitting and creating objects. This is I have so far.
I have tried this as well:
projection is also object, which I obtained, this is just reference, it is elsewhere in servlet. loggedInUser I got from session. I'm newbie regarding Java streams, any additional explanation would be excellent. I hope I correctly used flatMap to avoid Stream<String>.
I get that map() requires IntUnaryOperator lambda expression, something like this:
I don't know how to "map" from int (primary key for Seat) to Seat object.
You shouldtest output of each individual transformation you are applying, if you are not sure. For your case:
1. When you are using String::split to remove "seats=" prefix, the first part is an empty string, and the second part is the string that you want. So, you should use  to access that part. So, you should remove Arrays::stream method, because you have only one part per "seats=xx" string.
2. For constructing Seat from integer, you can use constructor as a method reference - Seat::new. Of course, you can use plain lambda as well like this: (i -> new Seat(i))
I agree with Dave. Code that uses streams generally should tell intent, which is kind of the point of functional style programming (vs. imperative style). By using the stream to split the string into component parts like that, you're adding a lot of implementation detail into the mix. If anything, keep the parsing of the input separate from the stream code.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck