I want to change method annotation using reflection in java
here is a snapshot:
can you suggest?.
final List<Method> allMethods = new ArrayList<Method>(Arrays.asList(klass.getDeclaredMethods()));
Method thisMethod = allMethods.stream().filter(m->m.getName() == "getWithPathParam" ).findFirst().get();
Annotation[][] parameterAnnotations = thisMethod.getParameterAnnotations();
for(Annotation[] annotations : parameterAnnotations){
for(Annotation annotation : annotations){
if(annotation instanceof ApiParam){
Annotation newAnnotation = new ApiParam() {
@Override
public String allowableValues() {
return "test";
}
@Override
public Class<? extends Annotation> annotationType() {
return annotation.annotationType();
}
};
here I want basically to exchange annotation field with newAnnotation field
it is possible?
Aucun commentaire:
Enregistrer un commentaire