IntelliJ 8: Type Migration

07 Nov, 2008

Coding is refactoring. What starts with a great idea, might prove incorrect in the future. A simple example is the following code:

public class Address {
    private String streetName;
    private Integer houseNumber;
    // getters and setters

While initialy, a housenumber represented as an Integer might sound like a valid thing to do, chances are that this might change in the future when you need to handle
housenumbers like ’21A’, or ’19 4th story’. However, your UI expects this to be a Integer. Your domain expects this to be an integer. Your service layer expects this to be an integer.
I guess you catch my drift. Until now, it took quite some effort to refactor this, since you cannot just rename an Integer to a String. Now, with the help of Type Migration, this is possible!
By selecting the Integer type in the Address, and pressing Ctrl+Shift+F6 (Refactor -> Type Migration), you can change the type of the housenumber to be a String. The
great thing about this is that the getters and setters automatically change, but also methods which call this method. For example, if I have this code in the Person class:

    public Integer getPersonHouseNumber() {
        return address.getHouseNumber();

Changing the type of the house number property in the address class will have the following result:

    public String getPersonHouseNumber() {
        return address.getHouseNumber();

So, the type did not only change in the Address class, but in the whole chain of method calls! This saves a lot of time in refactoring, and means that when changing
types at the DAO level, this change will automatically affect the whole call chain, for example up to the level of the UI.

Newest Most Voted
Inline Feedbacks
View all comments
13 years ago

Your kidding right? Eclipse did that years ago.
Please. intelliJ. STOP.

13 years ago

Hello “Erik”,
As a long time eclipse user I have recently changed companies and am now forced to work with intellij by the higher powers …
It saddens me to see so many good features lacking in the intellij tool … I am really giving it a shot learning all the shortcuts etc, but there are lots of things that are just not possible.
Another feature I dearly miss is ctrl-3 or quick assist in eclipse which basicly gives you access to everything without having to know the shortcut, just type in what you want and you shall receive!
Code templates like intelligent for-eaches etc … having just ONE key-combo for a DECENT auto complete is also great to have … oh eclipse, how I miss you during these long cold days working with the ugly looking swing app which often has an unresponsive ui on a quadcore with 4gig ram … you will always treasured!

Erik Pragt
13 years ago

Hi Bill,
If you miss some features in IntelliJ, don’t hesitate to ask for them on the forum ( or make a Jira ( The IntelliJ team is known to be open for any kind of suggestions so if you have any specific request, you can aks them there.
Regarding your ctrl+3: I think the IntelliJ equivalent of Ctrl+3 is ‘Goto->Action’ (shift+command+a on MacOS).
Code templates is called a ‘Live template’ (command+j on MacOS), the one key combo for autocomplete might be something to get used to, but at least it’s better than to have no option to do smart code completion (for example, not being able to filter out ‘compatible’ methods) in Eclipse.
So, in short, I would suggest reading the Reference Card for the shortcut, it really helps a lot. Or use the Eclipse compatible keymap.
BTW: Why would you let people force you which IDE to use?? If you want to use Eclipse, use Eclipse. Or any other IDE! I think there are more pressing things to worry about than your IDE, and if you’re more comfortable with Eclipe, the option seems obvious.

Explore related posts