Java refactoring