kotlin - 你能定义 Kotlin Annotations 的替代简写吗?
问题描述
我正在使用注释和反射为我使用的项目中使用的一些自定义文件创建解析器
我有这个注释,将用于注释大多数数据类构造函数参数
annotation class Element(val name: String = "",val type: ElementType = ElementType.Value)
枚举 ElementType 具有这些值
enum class XElementType {
Value,
Attribute,
Ignore
}
有没有办法创建一个速记或替代,而不是使用
@Element(type=ElementType.Ignore)
val ignoredVariable:String
我可以使用类似的东西
@IgnoreElement
val ignoredVariable:String
哪个会解决Element("",ElementType.Ignore)
?
解决方案
推荐阅读
- timer - Arduino中的定时器寄存器可以延迟2秒吗?
- php - 如何计算多维数组
- java - 从另一个类设置 TextView 文本
- python - Python:从列表中删除字符
- regex - 正则表达式:抓取分配给属性的 JS 函数的内容
- reactjs - 如何在 Draftjs 中突出显示文本
- node.js - Sails.js:由于用法不明确,无法填充模型
- android - Firebase 云消息传递:Oreo 中的通知图标问题
- spring-boot - Zipkin UI 显示错误消息“错误:无法加载服务名称:无可用消息”
- apache-flink - 在不中断执行的情况下更改 Flink 中的源函数