如何在Eclipse中使用JavaDocs来显示条件返回语句?

时间:2015-02-10 16:48:34

标签: javadoc

我有一个简单的方法“ValidateUser”,它根据用户是否已成功登录返回不同的字符串。

Output specifications

现在我刚刚记录了第一个可能的输出。

/**
*
*@param user the username of the user
*@param password the password of the user
*@return    True <br>
*           User_First_Name<br>
*           User_Last_Name<br>
*           Num_Records
*
*/

使用javadocs显示所有可能输出的最佳方法是什么?

1 个答案:

答案 0 :(得分:4)

一个选项是保持@return简单,并将详细信息放在方法文档中。

例如:

/**
* Validates the user.
* <p>If successful, returns a string including these lines:</p>
* <blockquote>
* TRUE
* User_First_Name
* User_Last_Name
* Num_Records
* </blockquote>
* <p>Otherwise, returns "FALSE" or "FAILED".</p>
* @param user the username of the user
* @param password the password of the user
* @return  If successful, the multi-line string described above, 
*    beginning with "TRUE". Returns "FALSE" if the user credentials 
*    are invalid. Returns "FAILED" if the operation failed for any 
*    reason (e.g., can't connect to the server, internal server error).
*/