[Java] Code refactoring