jnovacho
jnovacho

Reputation: 2903

Overload Javadoc in inheriting class

I have following functional hierarchy which I'm recreating in Java:

   Diagram
     |
     |--Model
          |
          |--Entity

All those object share some common properties (id, name) and also an reference to parent object in hierarchy. So I have implemented an abstract class:

abstract class DBObject{
   private final int id;
   private final String name;
   private final DBObject parent;

   //constructors, getters, setters here

   /**
    * @return reference to parent object in hierarchy.
    */
    public final getParent(){
       return parent;
    }
}

So far no problem. The thing is, that Diagram has no parent and will always return null. This is ensured by implementation. But I would like to reflect the "parent always null" in Diagram Javadoc. Is it possible to overload Javadoc, without overriding method? Solution would be to state that in abstract class as a note, but that's no an answer I'm looking for.

Thanks.

Upvotes: 1

Views: 316

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533880

To replace the Javadoc you have to override the method in the child class.

E.g.

Iterator.iterator() is overridden in
Collection.iterator() which is overridden by
Set.iterator() which is overridden by
NavigableSet.iterator() just to give each a different Javadoc.

Upvotes: 1

Abhinav Sarkar
Abhinav Sarkar

Reputation: 23812

How about this?

/**
* @return reference to parent object in hierarchy. may be null.
*/
@Nullable
public final DBObject getParent(){
   return parent;
}

Upvotes: 1

Related Questions