Hi Andrea, #flatMap() has been introduced after this dicussion: http://markmail.org/message/i34iulxttjc7umij I am not an expert in Category theory so maybe this is not the best impl but the implementation of iModel#flatMap() is more like Optional#flatMap() than Stream/Collections' #flatMap()
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Jul 15, 2016 at 1:22 PM, Andrea Del Bene <[email protected]> wrote: > Hi guys, > > I need some help with the new method IModel#flatMap as I don't completely > get the idea behind it. I've got two main questions: > - Why "flat" in the name? It sounds a little misleading to me. With Stream > is quite clear what flatMap does: it gets new streams out of each element > end merge them into an unique stream. But in this case I don't understand > what "flat" means. > - Looking at the test code I see that the main difference between map and > flatMap is that the first creates a read-only model, while the second uses > a wrapping model that might be a read/write one. If so wouldn't be better > to provide a second map method with a WicketConsumer as additional > parameter? Example: Model.of(person).map(Person::getName, Person::setName); > > Cheers. > > Andrea. >
