Is there a way to make classes final by default in Eclipse? i.e: on save actions, or in the create new class dialog?
This truly is a hack, but what you can do in your eclipse settings is set the following code template:
Under Java > Code Style > Code Templates > Code > New Java Files, you can add the final
keyword right before ${type_declaration}
.
The caveat is that the final checkbox is no longer properly functional, but if you are someone that blows through the New Class dialog before clicking a box in the first place, then it may be a lesser evil to remove final
in the actual code afterwards in the 10% of cases you need it.
The other caveat is that the first line of the class will look like final public MyClass
; while still valid, it is not the more idiomatic public final MyClass
.
Click on final check box in new class dialog.
Also take a look at this: How to create a custom 'new class wizard' for Eclipse?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With