Reputation: 1952
I want to get the value of other property in scope of annotation.
example
@WebMethod(operationName = "GetBatchCount", action = NAMESPACE + getOperationName())
getOperationName()
should return value set to operationName
.
Is it possible?
Upvotes: 1
Views: 51
Reputation: 13344
From JLS §9.7.1 (emphasis is mine) the following are allowed combinations in element-value pairs:
The type of V is assignment compatible (§5.2) with T, and furthermore:
- If T is a primitive type or String, and V is a constant expression (§15.28).
- V is not null.
- If T is Class, or an invocation of Class, and V is a class literal (§15.8.2).
- If T is an enum type, and V is an enum constant.
So, as you can see, value can be only a constant of sorts.
Upvotes: 1
Reputation: 7504
No, you cannot use a method inside the parameter block of an annotation.
Upvotes: 0