首页 > 解决方案 > 你能定义 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)

标签: kotlinannotations

解决方案


推荐阅读