Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 783
user2482822 Avatar asked May 14 '15 01:05

user2482822


2 Answers

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
like image 150
guido Avatar answered Oct 21 '22 00:10

guido


You add an @param tag for T to your Javadoc.

Something like this:

/**
 * ... other comments here ...
 * @param T The expected class of the value.
 * @param request ... other comments here ...
 * @param expected ... other comments here ...
 * @return ... other comments here ...
 */
public <T extends Object> T getExpectedValue(
    final HttpServletRequest request, final Class<T> expected)

If you aren't using Javadoc, then you probably shouldn't have Javadoc warnings enabled.

like image 25
user253751 Avatar answered Oct 20 '22 23:10

user253751