Different design patterns in java 8 and scala