How to override javadoc for final method in subclass?

public class BaseClass {
    /**
     * Gets the value.
     */
    public final String getValue() {
        // returns something.
    }
}

public class SubClass extends BaseClass {
    /**
     * Gets the value.
     * <p/>
     * The value is meaningless for SubClass.
     */
    @Override // Cannot override final method
    public final String getValue() {
        super.getValue(); // Not overriding implementation, just javadoc
    }
}

I don't need to change the implementation of the final method, I just want to change the Javadoc for it.

+4
source share
2 answers

Simply put: you cannot do this. If at all, you can put some javadoc in the definition of this child class, explaining that the behavior of this final method has been changed. And if you can do this, you can change the javadoc in the base class to say: “a subclass can invalidate this method” or something like that.

In addition, you must understand that this is also a dubious idea.

. , A -a B, A B. , , . (. , ).

, final - . , . : " , !"

+7

Java, Java. , , .

API Javadoc (API Doclet) , . Javadoc . , - .

: . GhostCat, , .

+2

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


All Articles