Example usage for java.lang.reflect Parameter isNamePresent

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

Introduction

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

Prototype

public boolean isNamePresent() 

Source Link

Document

Returns true if the parameter has a name according to the class file; returns false otherwise.

Usage

From source file:io.silverware.microservices.providers.cdi.internal.RestInterface.java

private static String getParamName(final Parameter methodParameter, Method method, final Class<?> clazz) {
    final ParamName paramName = methodParameter.getAnnotation(ParamName.class);
    if (paramName != null && paramName.value() != null && !paramName.value().trim().isEmpty()) {
        return paramName.value().trim();
    }// w  ww  .ja  v a2 s.  c  om
    final JsonProperty jsonProperty = methodParameter.getAnnotation(JsonProperty.class);
    if (jsonProperty != null && jsonProperty.value() != null && !jsonProperty.value().trim().isEmpty()) {
        return jsonProperty.value().trim();
    }

    if (!methodParameter.isNamePresent()) {
        log.warn(String.format(
                "Method parameter name is not present for method %s in class %s. Please use compilation argument (or test compilation argument) \"-parameters\""
                        + " or use annotation @%s or @%s for parameters of this method.",
                method.getName(), clazz.getCanonicalName(), ParamName.class.getCanonicalName(),
                JsonProperty.class.getCanonicalName()));
    }
    return methodParameter.getName();
}