java - Is there any way to use an annotation's value in another annotation? -
i have several runtime annotations in codes , have duplicated value of them, example:
@a(value="/get") @b(value="/get") @c(value="/get") public void methoda(){} is there way can use predefined annotation's value? such as:
@a(value="/get") @b(value=a.value) @c(value=a.value) public void methoda(){}
the specification requires annotation values compile-time constants, cannot reference annotation's value @ compile time, can share same compile-time constant:
private static final string common = "/get"; @a(value=common) @b(value=common) @c(value=common) public void methoda() { /* ... */ }
Comments
Post a Comment