Search code examples
javaannotationsintellij-idea

IntelliJ is it possible to add @Overrides to all methods of a particular interface?


I have created an interface, with about 30 methods and implemented in 30 classes.

I want to add @Override to each of the implementations, but i would like not to do it by hand.

How can IntelliJ help me?

interface looks like this:

public interface PreviewObjectTests {
    void testGetName();
    void testGetType();
    //... 30 similar methods
}

implementation code:

public class PreviewObjectAccountTest implements PreviewObjectTests {

    //I want to add @Override here!
    @Test public void testGetName() {
        assertThat(...);
    }

    //I want to add @Override here!
    @Test public void testGetType() {
        assertThat(...);
    }

    //...30 similar methods 

}

Solution

  • Easily done with Alt+Enter intention, then press Right arrow for the sub-menu:

    Fix all