Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javadoc when extending generic class with non-generic class

Suppose I have two classes:

abstract class GenericA<E> {
    public void go(E e) {...}
}

public class IntegerA extends GenericA<Integer> {
}

Note that GenericA is package-private and generic, and IntegerA is public and not generic.

Now, when I generate the public Javadoc (using Eclipse), I see the following in the IntegerA methods section:

public void go(E e)

The problem is that a reader of that Javadoc has no idea what E is; i.e., that E represents Integer. I would rather have the Javadoc say

public void go(Integer e)

Is there a way to make Javadoc behave the way I want it to?

like image 976
Blaine Avatar asked Oct 02 '12 19:10

Blaine


People also ask

Can a generic class extend a non generic class?

In this post, We will discuss some very interesting points about generic classes and their inheritance. A generic class can extend a non-generic class.

Can you extend a generic class?

Generic Classes and SubtypingYou can subtype a generic class or interface by extending or implementing it. The relationship between the type parameters of one class or interface and the type parameters of another are determined by the extends and implements clauses.

Can we extend generic class in Java?

Yes, you can use any valid Java identifier for type parameters.

How do you restrict the types used as type arguments in generic classes and methods?

Whenever you want to restrict the type parameter to subtypes of a particular class you can use the bounded type parameter. If you just specify a type (class) as bounded parameter, only sub types of that particular class are accepted by the current generic class. These are known as bounded-types in generics in Java.


1 Answers

Only way I know is override method in IntegerA with Integer and then call super method.

 @Override
 public void go(Integer e) {
    super.go(e);
}
like image 148
Amit Deshpande Avatar answered Oct 15 '22 23:10

Amit Deshpande