add defaultWhenNull method and local variant support
source refactoring and add java docs