List of usage examples for java.lang.reflect Parameter getAnnotation
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
From source file:org.jspare.server.transaction.TransactionExecutorImpl.java
/** * Resolve parameter.//from w w w. j a v a2s. co m * * @param parameter * the parameter * @param request * the request * @param response * the response * @return the object */ private Object resolveParameter(Parameter parameter, Request request, Response response) { if (parameter.getType().equals(Request.class)) { return request; } if (parameter.getType().equals(Response.class)) { return response; } if (!StringUtils.isEmpty(request.getParameter(parameter.getName()))) { return request.getParameter(parameter.getName()); } if (parameter.getType().getPackage().getName().endsWith(".model") || parameter.getType().isAnnotationPresent(Model.class) || parameter.isAnnotationPresent(Model.class)) { try { return my(Serializer.class).fromJSON(String.valueOf(request.getEntity().get()), parameter.getType()); } catch (SerializationException e) { log.warn("Invalid content of entity for class [{}] on parameter [{}]", parameter.getClass(), parameter.getName()); return null; } } if (parameter.isAnnotationPresent(org.jspare.server.mapping.Parameter.class)) { String parameterName = parameter.getAnnotation(org.jspare.server.mapping.Parameter.class).value(); return request.getParameter(parameterName); } return null; }
From source file:org.mule.runtime.extension.api.util.NameUtils.java
public static String getAliasName(Parameter parameter) { return getAliasName(parameter.getName(), parameter.getAnnotation(Alias.class)); }