如何创建自己的批注可选参数? [英] How to create optional parameters for own annotations?

查看:139
本文介绍了如何创建自己的批注可选参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是注释code

public @interface ColumnName {
   String value();
   String datatype();
 }

我想作数据类型可选参数,例如:

@ColumnName(value="password") 

应该是一个有效的code。

should be a valid code.

推荐答案

好像在的official文档说,这一切...

Seems like the first example in the official documentation says it all ...

/**
 * Describes the Request-For-Enhancement(RFE) that led
 * to the presence of the annotated API element.
 */
public @interface RequestForEnhancement {
    int    id();
    String synopsis();
    String engineer() default "[unassigned]"; 
    String date()     default "[unimplemented]"; 
}

这篇关于如何创建自己的批注可选参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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