In the following topics:
it is discussed how to create an instance of a Java annotation.
My question is: having such an annotation instance, what can I do with it? In particular, can I somehow apply it on a method's parameter?
Motivation:
I'm preparing several Azure Functions and I don't like the fact that I need to repeat many times code like
@HttpTrigger(name = "req", methods = {HttpMethod.GET}, route= "/api/mypath", authLevel = AuthorizationLevel.ANONYMOUS)
So I thought I'd create a method HttpTrigger createHttpTrigger(HttpMethod httpMethod) { ... }
and then instead of
@FunctionName("MyFunction")
public HttpResponseMessage getModelNames(
@HttpTrigger(name = "req", methods = {HttpMethod.GET}, route= "api/mypath", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
...
}
write something like
@FunctionName("MyFunction")
public HttpResponseMessage getModelNames(
@createHttpTrigger(HttpMethod.GET) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
}
(but of course this code is incorrect)