How to use type refactoring to replace java.util object with custom wrapper? (e.g. Locale)

Hi all,

We want to replace all referenes to java.util.Locale in a project with a custom LocaleWrapper, in order to add attributes to the Locale.

Type Refactoring: Can it do this?
Can I use intellij type refactorng to replace, project-wide, all java.util.Locale references with our custom class? Specifically, I'd like to do this in one shot.

In order to minimize errors: we have given the LocaleWrapper class all the same methods as the Locale --i.e. it delegates to the contained Locale.

public class LocaleWrapper
  private Locale fLocale

  public static String[] getISOCountries() {
     return fLocale.getISOCountries()



Post Refactoring Cleanup
I understand I would have some cleanup afterward--that's OK.

Results So Far

I've tried type refactoring a method on a 'base'  interface in the project and Idea hit nearly all references. It had a couple misses:
* It changed some interfaces, but not all the underlying implemenation

Any tips?


1 comment
Comment actions Permalink

Have you tried using a Structural Search and Replace (SSR)? I would think the case you are describing could be handled by such. See:


Please sign in to leave a comment.