/** * Check if the parameter is {@link ParamQualifier qualified}. * * @return {@code true} if the parameter is qualified, {@code false} otherwise. */ public boolean isQualified() { for (Annotation a : getAnnotations()) { if (a.annotationType().isAnnotationPresent(ParamQualifier.class)) { return true; } } return false; }
/** * Check if the parameter is {@link ParamQualifier qualified}. * * @return {@code true} if the parameter is qualified, {@code false} otherwise. */ public boolean isQualified() { for (Annotation a : getAnnotations()) { if (a.annotationType().isAnnotationPresent(ParamQualifier.class)) { return true; } } return false; }
@Override public Object apply(ContainerRequest containerRequest) { final Class<?> rawType = parameter.getRawType(); Object value; if ((Request.class.isAssignableFrom(rawType) || ContainerRequestContext.class.isAssignableFrom(rawType)) && rawType.isInstance(containerRequest)) { value = containerRequest; } else { value = containerRequest.readEntity(rawType, parameter.getType(), parameter.getAnnotations()); if (rawType.isPrimitive() && value == null) { throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST) .entity(LocalizationMessages.ERROR_PRIMITIVE_TYPE_NULL()).build()); } } return value; } }
@Override public Object apply(ContainerRequest containerRequest) { final Class<?> rawType = parameter.getRawType(); Object value; if ((Request.class.isAssignableFrom(rawType) || ContainerRequestContext.class.isAssignableFrom(rawType)) && rawType.isInstance(containerRequest)) { value = containerRequest; } else { value = containerRequest.readEntity(rawType, parameter.getType(), parameter.getAnnotations()); if (rawType.isPrimitive() && value == null) { throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST) .entity(LocalizationMessages.ERROR_PRIMITIVE_TYPE_NULL()).build()); } } return value; } }
@Override public void run() { int counter = 0; final Annotation[] annotations = parameter.getAnnotations(); for (Annotation a : annotations) { if (PARAM_ANNOTATION_SET.contains(a.annotationType())) { if (injectionsForbidden) { Errors.fatal(source, LocalizationMessages.SINGLETON_INJECTS_PARAMETER(reportedSourceName, reportedParameterName)); break; } counter++; if (counter > 1) { Errors.warning(source, LocalizationMessages.AMBIGUOUS_PARAMETER(reportedSourceName, reportedParameterName)); break; } } } final Type paramType = parameter.getType(); if (!isConcreteType(paramType)) { Errors.warning(source, LocalizationMessages.PARAMETER_UNRESOLVABLE(reportedParameterName, paramType, reportedSourceName)); } } });
@Override public void run() { int counter = 0; final Annotation[] annotations = parameter.getAnnotations(); for (Annotation a : annotations) { if (PARAM_ANNOTATION_SET.contains(a.annotationType())) { if (injectionsForbidden) { Errors.fatal(source, LocalizationMessages.SINGLETON_INJECTS_PARAMETER(reportedSourceName, reportedParameterName)); break; } counter++; if (counter > 1) { Errors.warning(source, LocalizationMessages.AMBIGUOUS_PARAMETER(reportedSourceName, reportedParameterName)); break; } } } final Type paramType = parameter.getType(); if (!isConcreteType(paramType)) { Errors.warning(source, LocalizationMessages.PARAMETER_UNRESOLVABLE(reportedParameterName, paramType, reportedSourceName)); } } });
@Override public MultivaluedParameterExtractor<?> get(final Parameter p) { return process( paramConverterFactory.get(), p.getDefaultValue(), p.getRawType(), p.getType(), p.getAnnotations(), p.getSourceName()); }
@Override public MultivaluedParameterExtractor<?> get(final Parameter p) { return process( paramConverterFactory.get(), p.getDefaultValue(), p.getRawType(), p.getType(), p.getAnnotations(), p.getSourceName()); }
final BindingModel binding = BindingModel.create(Arrays.<Annotation>asList(parameter.getAnnotations()));
final BindingModel binding = BindingModel.create(Arrays.<Annotation>asList(parameter.getAnnotations()));
private void checkParameters(ResourceMethod method) { final Invocable invocable = method.getInvocable(); final Method handlingMethod = invocable.getHandlingMethod(); int paramCount = 0; int nonAnnotatedParameters = 0; for (Parameter p : invocable.getParameters()) { validateParameter(p, handlingMethod, handlingMethod.toGenericString(), Integer.toString(++paramCount), false); if (method.getType() == ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR && Parameter.Source.ENTITY == p.getSource()) { Errors.fatal(method, LocalizationMessages.SUBRES_LOC_HAS_ENTITY_PARAM(invocable.getHandlingMethod())); } else if (p.getAnnotations().length == 0) { nonAnnotatedParameters++; if (nonAnnotatedParameters > 1) { Errors.fatal(method, LocalizationMessages.AMBIGUOUS_NON_ANNOTATED_PARAMETER(invocable.getHandlingMethod(), invocable.getHandlingMethod().getDeclaringClass())); } } } }
private void checkParameters(ResourceMethod method) { final Invocable invocable = method.getInvocable(); final Method handlingMethod = invocable.getHandlingMethod(); int paramCount = 0; int nonAnnotatedParameters = 0; for (Parameter p : invocable.getParameters()) { validateParameter(p, handlingMethod, handlingMethod.toGenericString(), Integer.toString(++paramCount), false); if (method.getType() == ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR && Parameter.Source.ENTITY == p.getSource()) { Errors.fatal(method, LocalizationMessages.SUBRES_LOC_HAS_ENTITY_PARAM(invocable.getHandlingMethod())); } else if (p.getAnnotations().length == 0) { nonAnnotatedParameters++; if (nonAnnotatedParameters > 1) { Errors.fatal(method, LocalizationMessages.AMBIGUOUS_NON_ANNOTATED_PARAMETER(invocable.getHandlingMethod(), invocable.getHandlingMethod().getDeclaringClass())); } } } }
parameter.getRawType(), parameter.getType(), parameter.getAnnotations(), mediaType); parameter.getRawType(), parameter.getType(), parameter.getAnnotations(), mediaType, request.getHeaders(), String.class, String.class, parameter.getAnnotations(), p.getMediaType()); String.class, String.class, parameter.getAnnotations(), mediaType, request.getHeaders(),
/** * Check if the parameter is {@link ParamQualifier qualified}. * * @return {@code true} if the parameter is qualified, {@code false} otherwise. */ public boolean isQualified() { for (Annotation a : getAnnotations()) { if (a.annotationType().isAnnotationPresent(ParamQualifier.class)) { return true; } } return false; }
@Override public Object apply(ContainerRequest containerRequest) { final Class<?> rawType = parameter.getRawType(); Object value; if ((Request.class.isAssignableFrom(rawType) || ContainerRequestContext.class.isAssignableFrom(rawType)) && rawType.isInstance(containerRequest)) { value = containerRequest; } else { value = containerRequest.readEntity(rawType, parameter.getType(), parameter.getAnnotations()); if (rawType.isPrimitive() && value == null) { throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST) .entity(LocalizationMessages.ERROR_PRIMITIVE_TYPE_NULL()).build()); } } return value; } }
@Override public void run() { int counter = 0; final Annotation[] annotations = parameter.getAnnotations(); for (Annotation a : annotations) { if (PARAM_ANNOTATION_SET.contains(a.annotationType())) { if (injectionsForbidden) { Errors.fatal(source, LocalizationMessages.SINGLETON_INJECTS_PARAMETER(reportedSourceName, reportedParameterName)); break; } counter++; if (counter > 1) { Errors.warning(source, LocalizationMessages.AMBIGUOUS_PARAMETER(reportedSourceName, reportedParameterName)); break; } } } final Type paramType = parameter.getType(); if (!isConcreteType(paramType)) { Errors.warning(source, LocalizationMessages.PARAMETER_UNRESOLVABLE(reportedParameterName, paramType, reportedSourceName)); } } });
@Override public MultivaluedParameterExtractor<?> get(final Parameter p) { return process( paramConverterFactory.get(), p.getDefaultValue(), p.getRawType(), p.getType(), p.getAnnotations(), p.getSourceName()); }
final BindingModel binding = BindingModel.create(Arrays.<Annotation>asList(parameter.getAnnotations()));
private void checkParameters(ResourceMethod method) { final Invocable invocable = method.getInvocable(); final Method handlingMethod = invocable.getHandlingMethod(); int paramCount = 0; int nonAnnotatedParameters = 0; for (Parameter p : invocable.getParameters()) { validateParameter(p, handlingMethod, handlingMethod.toGenericString(), Integer.toString(++paramCount), false); if (method.getType() == ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR && Parameter.Source.ENTITY == p.getSource()) { Errors.fatal(method, LocalizationMessages.SUBRES_LOC_HAS_ENTITY_PARAM(invocable.getHandlingMethod())); } else if (p.getAnnotations().length == 0) { nonAnnotatedParameters++; if (nonAnnotatedParameters > 1) { Errors.fatal(method, LocalizationMessages.AMBIGUOUS_NON_ANNOTATED_PARAMETER(invocable.getHandlingMethod(), invocable.getHandlingMethod().getDeclaringClass())); } } } }
@Override public MultivaluedParameterExtractor<?> get(final Parameter p) { return process( paramConverterFactory, p.getDefaultValue(), p.getRawType(), p.getType(), p.getAnnotations(), p.getSourceName()); }