Maven checkstyle error : Expected @param tag for '<T>'

user2482822 picture user2482822 · May 14, 2015 · Viewed 9.6k times · Source

I have following method with generic types, but when I run maven checkstyle(maven-checkstyle-plugin, 2.121) it kept gives me Expected @param tag for '<T>' error message during maven build. How do I get over with this?

/**
 * Read in specified type of object from request body.
 * @param request The HttpServletRequest
 * @param expected The expected type T
 * @return <T> specified type of object
 */
public <T extends Object> T getExpectedValue(
    final HttpServletRequest request, final Class<T> expected)

I used following to turn generic param tag off, but it didn't work and I have above mentioned java doc as well.

<module name="JavadocType">
    <property name="allowMissingParamTags" value="true"/>
</module>

Answer

guido picture guido · May 14, 2015

It is telling you that you did not write the javadoc for the method type parameter:

/**
 * ...
 * @param <T> This is the type parameter
 * @param ....
 */
 public <T extends Object> T getExpectedValue(
        final HttpServletRequest request, final Class<T> expected)

the produced javadoc will include a section like the following in the header:

Type Parameters: 
    T - This is the type parameter