If I have a SetMultimap like the following:
SetMultimap<String, MyObject> map = HashMultimap.create();
map.put("a", new MyObject());
map.put("a", null);
map.put("b", null);
What is the best way to remove the null values from this collection, so that I end up with something like (i.e. some keys will have only null values, but I still want the key):
a -> obj
b -> empty
Multimap<String, String> filteredMap = Multimaps.filterValues(map, Predicates.notNull());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With