liuhaozzu opened a new pull request #81: add lambdas function to provide default value in MapUtils URL: https://github.com/apache/commons-collections/pull/81 For the code MapUtils.getString(map, key, defaultValue);, the default value is not always a constant. Sometimes we may need to do some calculate. Sometimes I do it like this: MapUtils.getLong(map, key, getDefaultValue()); private Long getDefaultValue() { return System.currentTimeMillis(); } you see, now the problem is that even if the value associated with the key exists, the getDefaultValue method will still be invoked and excuted which is a kind of waste. As we can use lambdas in Java8 or above, there is a better way to do it now. MapUtils.getLong(map, key, (key)->{ return System.currentTimeMillis(); }); by passing a lambdas to provide the default value, the lambdas will only be excuted when the value does not exist.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services