使用JavaDoc记录地图的标准方法是什么? [英] What is the standard way to use JavaDoc to document a Map?

查看:63
本文介绍了使用JavaDoc记录地图的标准方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在记录一些代码,并且有一个私有的HashMap.我想指定有关键和值所期望的信息.现在我有:

I'm documenting some code, and I have a private HashMap. I'd like to specify information about what is expected from the key and value. Right now I have:

/**
 * HashMap where key=word, value=part of speech
 */
private HashMap<String, String> dictionary;

但是,这似乎很难读懂,而且当我遇到更复杂的内容时,它也无法正常工作

However, this seems hard to read, and also like it won't work well when I have something more complex like

HashMap<String, HashMap<String, String>>

记录地图的最佳/常见做法是什么?

What are best/common practices for documenting maps?

推荐答案

如果您需要一个小的Javadoc,我建议您执行以下操作:

If you need a small javadoc, I suggest the following:

/**
 * Dictionary is a {@link Map} collection that contains {@link Object1} as
 * key and {@link Object2} as value.
 */
private Map<Object1, Object2> dictionary = new HashMap<>();

@link键盘操作会将您重定向到实例定义.

@link keywork will redirect you on instance definition.

注意:最好使用接口作为类型(使用Map代替HashMap).

Note : Using an interface as a type (Map instead of HashMap) should be preferred.

这篇关于使用JavaDoc记录地图的标准方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆