Example usage for java.lang.reflect Parameter getDeclaredAnnotation

List of usage examples for java.lang.reflect Parameter getDeclaredAnnotation

Introduction

In this page you can find the example usage for java.lang.reflect Parameter getDeclaredAnnotation.

Prototype

public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) 

Source Link

Usage

From source file:telegram.polling.BotApiProxy.java

@Override
public Object invoke(Object o, Method method, Object[] os) throws Throwable {
    ArrayList<NameValuePair> nvps = new ArrayList<>();
    for (int i = 0; i < method.getParameterCount(); i++) {
        Parameter parameter = method.getParameters()[i];
        if (os[i] != null) {
            String name;//from   w  w w . j av a  2 s .c o  m
            if (parameter.isAnnotationPresent(Param.class)) {
                name = parameter.getDeclaredAnnotation(Param.class).name();
            } else {
                name = parameter.getName();
            }
            nvps.add(new BasicNameValuePair(name, os[i].toString()));
        }
    }
    return callApiMethod(method.getName(), nvps, method.getReturnType());
}