Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify Eclipse equals() method template

Tags:

java

eclipse

The eclipse generated equals() method does not have { } for if structure. e.g

public boolean equals(Object obj) {
    if (this == obj)
        return true;
    .........
    return true;
}

How can it be changed to generate code in following patter

public boolean equals(Object obj) {
    if (this == obj){
        return true;
    }
    .........
    return true;
}
like image 970
amique Avatar asked Mar 18 '23 23:03

amique


1 Answers

You can use the check Use blocks in if statements of the Generate hashcode and equals option to generate the brackets, like this:

Check the use blocks in if statements

And the code generated will look like:

enter image description here

Another option is use the Save actions feature, and add a format sourcecode action.

Cheers

like image 53
Arturo Volpe Avatar answered Mar 29 '23 10:03

Arturo Volpe