Opposing tag for @Override in Java

I know that in Java there is a tag @Overrideto annotate a method that overrides a method from a superclass if there is no warning. My question is: is there an opposite tag for annotating a method that we don’t want to override the method from the superclass (for example, by accident)?

I know that I can set the method in a superclass final, but this solution includes changes to the code of the superclass. This is what I do not want to do - I just want to change my code :)

I know that I can set a different name for this method, but sometimes there are many methods in the superclass, and you just don't know about them. Therefore, when you implement your own in a subclass, you can accidentally use the same name. How to avoid this?

+4
source share
3 answers

No, there is no predefined Java annotation, which is an inverse @Override.

Having said that, most IDEs should be able to determine if a method overrides another. For example, Eclipse has this feature. If you look at your class in the Contour view, you will see a small triangle in which overrides occur. For instance:

enter image description here

I have to believe that NetBeans and IntelliJ Idea should have similar features.


, , , , , , , ( Swing ). - GUI - JPanel getX() getY()). , , .

+5

NetBeans, . , NetBeans .

, @override, , , /, , , .

+1

Give the method in the subclass a different name or signature than the method of the superclass that you do not want to override.

0
source

Source: https://habr.com/ru/post/1537377/


All Articles