Trying to translate this project to scala implementation or java8 implementation.(also helps reviewing code)