java - 是否有任何 @MustCall 注释或如何强制使用注释为新对象调用方法?
问题描述
我知道@CheckResult
注释和抽象方法。但我的需求略有不同。
Class MyCustomAlert {
/* blah blahs */
@MustCall
public void show() {
// this method shows the dialog
}
}
...
MyCustomAlert alert = new MyCustomAlert();
...
现在我想要的是,lint(Android 工作室)应该像“ You forgot to call method 'show()'
”一样警告我
这意味着MyCustomAlert
类的每个新对象都必须调用该方法show()
。
android中是否有任何@MustCall
或类似的注释?
解决方案
推荐阅读
- c# - 在 WPF 中设置 DynamicResouce 图标的颜色
- java - Gradle 构建:Java - 编译器错误
- java - java.lang.ClassNotFoundException 未指定缺少的类
- hadoop - Flume 代理不包含任何有效通道
- javascript - 将 SVG 转换为 jQuery 函数
- azure - 如何将数据湖存储中的文件夹作为参数传递给管道?
- javascript - 在javascript中自然排序包含数字、字母和日期和时间的字符串
- android - 当我单击图像按钮时,获取 recyclerview 项目的位置
- windows-10 - 制作一个单一的按钮睡眠/唤醒 Windows 10
- javascript - Phaser 2 如何在 Phaser.sprite.call 中使用动画