Search in sources :

Example 6 with MatrixParam

use of javax.ws.rs.MatrixParam in project cxf by apache.

the class ResourceUtils method getParameter.

// CHECKSTYLE:OFF
public static Parameter getParameter(int index, Annotation[] anns, Class<?> type) {
    Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
    if (ctx != null) {
        return new Parameter(ParameterType.CONTEXT, index, null);
    }
    boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
    BeanParam bp = AnnotationUtils.getAnnotation(anns, BeanParam.class);
    if (bp != null) {
        return new Parameter(ParameterType.BEAN, index, null, isEncoded, null);
    }
    String dValue = AnnotationUtils.getDefaultParameterValue(anns);
    PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
    if (a != null) {
        return new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
    }
    QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
    if (q != null) {
        return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
    }
    MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
    if (m != null) {
        return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
    }
    FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
    if (f != null) {
        return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
    }
    HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
    if (h != null) {
        return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
    }
    CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
    if (c != null) {
        return new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
    }
    return new Parameter(ParameterType.REQUEST_BODY, index, null);
}
Also used : Context(javax.ws.rs.core.Context) JAXBContext(javax.xml.bind.JAXBContext) CookieParam(javax.ws.rs.CookieParam) MatrixParam(javax.ws.rs.MatrixParam) HeaderParam(javax.ws.rs.HeaderParam) Encoded(javax.ws.rs.Encoded) QueryParam(javax.ws.rs.QueryParam) Parameter(org.apache.cxf.jaxrs.model.Parameter) PathParam(javax.ws.rs.PathParam) FormParam(javax.ws.rs.FormParam) BeanParam(javax.ws.rs.BeanParam)

Example 7 with MatrixParam

use of javax.ws.rs.MatrixParam in project tomee by apache.

the class ResourceUtils method getParameter.

// CHECKSTYLE:OFF
public static Parameter getParameter(int index, Annotation[] anns, Class<?> type) {
    Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
    if (ctx != null) {
        return new Parameter(ParameterType.CONTEXT, index, null);
    }
    boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
    BeanParam bp = AnnotationUtils.getAnnotation(anns, BeanParam.class);
    if (bp != null) {
        return new Parameter(ParameterType.BEAN, index, null, isEncoded, null);
    }
    String dValue = AnnotationUtils.getDefaultParameterValue(anns);
    PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
    if (a != null) {
        return new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
    }
    QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
    if (q != null) {
        return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
    }
    MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
    if (m != null) {
        return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
    }
    FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
    if (f != null) {
        return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
    }
    HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
    if (h != null) {
        return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
    }
    CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
    if (c != null) {
        return new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
    }
    return new Parameter(ParameterType.REQUEST_BODY, index, null);
}
Also used : Context(javax.ws.rs.core.Context) CookieParam(javax.ws.rs.CookieParam) MatrixParam(javax.ws.rs.MatrixParam) HeaderParam(javax.ws.rs.HeaderParam) Encoded(javax.ws.rs.Encoded) QueryParam(javax.ws.rs.QueryParam) Parameter(org.apache.cxf.jaxrs.model.Parameter) PathParam(javax.ws.rs.PathParam) FormParam(javax.ws.rs.FormParam) BeanParam(javax.ws.rs.BeanParam)

Aggregations

MatrixParam (javax.ws.rs.MatrixParam)7 Annotation (java.lang.annotation.Annotation)5 CookieParam (javax.ws.rs.CookieParam)5 PathParam (javax.ws.rs.PathParam)5 QueryParam (javax.ws.rs.QueryParam)5 FormParam (javax.ws.rs.FormParam)4 HeaderParam (javax.ws.rs.HeaderParam)4 Type (java.lang.reflect.Type)3 List (java.util.List)3 BeanParam (javax.ws.rs.BeanParam)3 Parameter (io.swagger.v3.oas.models.parameters.Parameter)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Consumes (javax.ws.rs.Consumes)2 Encoded (javax.ws.rs.Encoded)2 Context (javax.ws.rs.core.Context)2 Parameter (org.apache.cxf.jaxrs.model.Parameter)2 JsonView (com.fasterxml.jackson.annotation.JsonView)1 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)1