I have a javadoc code block where I want to write a code sample that includes generics like this:
public interface SomeInterface <T> { }
public interface SomeInterface extends SomeOtherInterface<T> { }
Here is my javadoc block:
/**
* Get the Generic Type T of a Type (Class/Interface) or extended/inherited Subtype:
* <pre>
* {@code
* public interface SomeInterface <T> { }
* public interface SomeInterface extends SomeOtherInterface<T> { }
* }
* </pre>
* @param implType
* @param parentType
* @return
*/
public static JClassType findGenericType(JClassType implType, JClassType parentType) { ... }
The javadoc output is:
Get the Generic Type T of a Type (Class/Interface) or extended/inherited Subtype:
public interface SomeInterface { }
public interface SomeInterface extends SomeOtherInterface { }
}
Parameters:
implType
parentType
Returns:
The Generic is missing in the output.
How can I get javadoc to display the generics correctly?
Java doc is rendered to HTML, so anything between angular brackets (<>
) would be interpreted as an HTML tag, and won't be printed as text.
You can use <
and >
in order to render HTML <
and >
respectively:
/**
* Get the Generic Type T of a Type (Class/Interface) or extended/inherited Subtype:
* <pre>
* {@code
* public interface SomeInterface <T> { }
* public interface SomeInterface extends SomeOtherInterface<T> { }
* }
* </pre>
* @param implType
* @param parentType
* @return
*/
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