How do I obtain the annotation from a parameter within the constructor arguments. I have tried...
Class<?>[] params = constructor.getParameterTypes();
if(params.length > 0) {
paramValues = new Object[params.length];
for(int i=0; i<params.length; i++) {
Annotation[] constructorAnnotations = params[i].getAnnotations(); //This does not work.
}
}
constructor.getParameterAnnotations() returns the annotations for each parameter. For example, the annotations for the 2nd parameter are:
Annotation[] annotations = constructor.getParameterAnnotations()[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With