Usage of Annotation
Obtains the values of annotations on an instance through reflection.
The code is as follows:
import std.reflect.*
main() {
let ti = TypeInfo.of(Test())
let annotation = ti.findAnnotation<A>()
if (let Some(a) <- annotation) {
println(a.name)
}
}
@A["Annotation"]
public class Test {}
@Annotation
public class A {
const A(let name: String) {}
}
The running result is as follows:
Annotation