Get the annotations attached to the entity instance.
Note that the returned annotations array contains only those annotations
explicitly attached to entity instance (such as the ones attached using
javax.ws.rs.core.Response.ResponseBuilder#entity(Object,java.lang.annotation.Annotation[]) method
as well as the ones attached to the resource method that has returned the response).
The entity instance annotations array does not include annotations declared on the entity
implementation class or its ancestors.
Note that container response filters invoked earlier in the filter chain may modify the entity annotations value,
in which case this getter method would return the last annotations value set by a container response filter invoked
earlier in the filter chain.
For example:
@Path("my-resource")
public class MyResource {
private final Annotations[] extras = ... ;
@GET
@Custom
public String getAnnotatedMe() {
return Response.ok().entity("Annotated me", extras).build();
}
...
}
The container response context for a response returned from the
getMe() method above would contain all
the annotations declared on the
getAnnotatedMe() method (@GET, @Custom) as well as all
the annotations from the
extras field, provided this value has not been replaced by any container response filter
invoked earlier.
Similarly:
@Custom
public class AnnotatedMe { ... }
@Path("my-resource")
public class MyResource {
private final Annotations[] extras = ... ;
@GET
public AnnotatedMe getMe() {
return Response.ok().entity(new AnnotatedMe(), extras).build();
}
...
}
Provided that the value has not been replaced by any container response filter invoked earlier,
the container response context for a response returned from the
getMe() method above would contain all
the annotations on the
getMe() method (@GET) as well as all the annotations from the
extras field. It would however not contain any annotations declared on the
AnnotatedMe class.