IntelliJ IDEA 14.1 Ships with Nextgen of Code Generation

IntelliJ IDEA already has impressive code generation capabilities: it can create getters and setters, equals(), hashCode(), toString(), and other methods, some of which are really simple to generate, and some are quite not.

That’s why the toString() method generator included the support for Velocity templates that could be modified and tailored to your needs. In IntelliJ IDEA 14.1 we’re extending this support to all other generated methods.


To fully support this new feature, the Template Editor has been upgraded with complete Velocity coding assistance.


Note that this particular editor improvement is only available in the Ultimate Edition, because it requires Velocity plugin, but everything else works well in Community Edition.

After the code has been generated, IntelliJ IDEA will make it clean and good-looking with automatic application of code style, Code Cleanup, and adding @Override annotations where needed.

If you’d like to give this feature a try, grab the latest IntelliJ IDEA 14.1 EAP build, and share your feedback with us on our discussion forum and in the issue tracker.

Develop with Pleasure!

This entry was posted in EAP Releases, New Features and tagged , , . Bookmark the permalink.

13 Responses to IntelliJ IDEA 14.1 Ships with Nextgen of Code Generation

  1. Korosif says:

    Can I use the new Velocity based template system with AS3/Flex in IntelliJ, or is it a Java only feature?
    By the way, it would be very useful when you talk about a feature if you can always disclose if it’s a Java only one, or if other language are concerned. I know it’s a Java centric IDE at core, but we’re quite a few that use IntelliJ for other things…

  2. Dmitry Kandalov says:

    Thank you, looks good.
    What about automatically regenerating these methods if class fields change?

  3. Alexander says:

    How to open this **** dialog?

    • Anna Kozlova says:

      Templates chooser is available over the member’s chooser. If you press ellipsis button, templates configurator would be shown

  4. John says:

    Any way to change the equalsHeader.vm?
    I want to have the generator add {} after every if statement

    • Anna Kozlova says:

      John, how is your code style configured? If it requires {} for if statements then generated code would contain them. In other words, generated code is automatically reformatted, so it is not expected that you need to change library part of the generators.


  5. Max says:


    Usually I use JGoodies binding and write data bean/model that extent a Model class (it has PropertyChangeSupport) and need to call following method in each setter:
    firePropertyChange( String propertyName, Object oldValue, Object newValue).

    For example, I define propertyName and coresponding field as: public static final String PROPERTY_DISPLAY_NAME = "displayName";
    private String m_DisplayName;

    I don’t know the syntax to write custom getter/setter code template. Want to ask how to make such a code template that will create the setter like following for that property:

    public void setDisplayName( final String in_NewValue ){

    final String oldValue = m_DisplayName;
    m_DisplayName = in_NewValue;
    firePropertyChange( PROPERTY_DISPLAY_NAME, oldValue, in_NewValue );



    • Anna Kozlova says:

      Hi, Max!

      You need to write velocity template. looks like that you can leave untouched default setter name but instead of part “$ = $paramName;” you need to write your code which stores old value to the temp variable:

      final String oldValue = $;
      $ = in_NewValue;
      firePropertyChange( PROPERTY_$StringUtil.toUpperCase($, oldValue, in_NewValue );

  6. snowdream says:

    I need a kotlin code generator!!!

  7. RK says:

    How can I break the equals() method into multiple methods:

    final class Foo {
    private final A a;
    private final B b;

    public boolean equals(Object obj) {
    return (this == obj) || ((obj instanceof Foo) && equalsOther((Foo)obj));

    private boolean equalsOther(Foo other) {
    return Objects.equals(a, other.a) &&
    Objects.equals(b, other.b);


Leave a Reply to Anna Kozlova Cancel reply

Your email address will not be published. Required fields are marked *