Got a question about the merge function with ConcurrentHashMaps. New to functional programming so not sure if I'm utilizing it correctly.
map.merge(consumer, val, (a, b) -> (a.date().compareTo(b.date())) >= 0 ? a : b);
What it should do if I've reasoned it out correctly is insert (consumer, val)
into the table if there is no existing entry. If there is, then it should compare the dates of a and b (value in table and my val). If "val" is > than the entry in the table, it should replace it with that. Otherwise, stick with existing entry.
Appreciate any help. Thanks!
Here's one example,
The third remapping function is used when there's a key conflict. Here's an excerpt from the documentation: