javax.ws.rs.MatrixParam Java Examples
The following examples show how to use
javax.ws.rs.MatrixParam.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MvcConverterProvider.java From ozark with Apache License 2.0 | 6 votes |
private static String getParamName(Annotation[] annotations) { for (Annotation annotation : annotations) { if (annotation instanceof QueryParam) { return ((QueryParam) annotation).value(); } if (annotation instanceof PathParam) { return ((PathParam) annotation).value(); } if (annotation instanceof FormParam) { return ((FormParam) annotation).value(); } if (annotation instanceof MatrixParam) { return ((MatrixParam) annotation).value(); } if (annotation instanceof CookieParam) { return ((CookieParam) annotation).value(); } } return null; }
Example #2
Source File: ClientProxyImpl.java From cxf with Apache License 2.0 | 6 votes |
protected void handleMatrixes(Method m, Object[] params, MultivaluedMap<ParameterType, Parameter> map, List<Parameter> beanParams, UriBuilder ub) { List<Parameter> mx = getParameters(map, ParameterType.MATRIX); mx.stream(). filter(p -> params[p.getIndex()] != null). forEachOrdered(p -> { addMatrixQueryParamsToBuilder(ub, p.getName(), ParameterType.MATRIX, getParamAnnotations(m, p), params[p.getIndex()]); }); beanParams.stream(). map(p -> getValuesFromBeanParam(params[p.getIndex()], MatrixParam.class)). forEachOrdered(values -> { values.forEach((key, value) -> { if (value != null) { addMatrixQueryParamsToBuilder(ub, key, ParameterType.MATRIX, value.getAnns(), value.getValue()); } }); }); }
Example #3
Source File: MatrixParameterResolverTest.java From everrest with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { matrixParameters = new MultivaluedHashMap<>(); matrixParameters.putSingle("foo", "to be or not to be"); matrixParameters.putSingle("bar", "hello world"); PathSegment firstPathSegment = mock(PathSegment.class); PathSegment lastPathSegment = mock(PathSegment.class); when(lastPathSegment.getMatrixParameters()).thenReturn(matrixParameters); applicationContext = mock(ApplicationContext.class, RETURNS_DEEP_STUBS); when(applicationContext.getUriInfo().getPathSegments(true)).thenReturn(newArrayList(firstPathSegment, lastPathSegment)); MatrixParam matrixParamAnnotation = mock(MatrixParam.class); when(matrixParamAnnotation.value()).thenReturn("foo"); parameter = mock(Parameter.class); when(parameter.getParameterClass()).thenReturn((Class)String.class); typeProducer = mock(TypeProducer.class); TypeProducerFactory typeProducerFactory = mock(TypeProducerFactory.class); when(typeProducerFactory.createTypeProducer(eq(String.class), any())).thenReturn(typeProducer); matrixParameterResolver = new MatrixParameterResolver(matrixParamAnnotation, typeProducerFactory); }
Example #4
Source File: ValidationExceptionMapper.java From seed with Mozilla Public License 2.0 | 6 votes |
private ParameterInfo resolveParameterInfo(Path.ParameterNode node, Method method) { if (method != null) { Annotation[][] parameterAnnotations = method.getParameterAnnotations(); int parameterIndex = node.as(Path.ParameterNode.class).getParameterIndex(); if (parameterIndex < parameterAnnotations.length) { for (Annotation a : parameterAnnotations[parameterIndex]) { if (a instanceof QueryParam) { return new ParameterInfo(Location.QUERY_PARAMETER, ((QueryParam) a).value()); } else if (a instanceof PathParam) { return new ParameterInfo(Location.PATH_PARAMETER, ((PathParam) a).value()); } else if (a instanceof HeaderParam) { return new ParameterInfo(Location.HEADER_PARAMETER, ((HeaderParam) a).value()); } else if (a instanceof CookieParam) { return new ParameterInfo(Location.COOKIE_PARAMETER, ((CookieParam) a).value()); } else if (a instanceof FormParam) { return new ParameterInfo(Location.FORM_PARAMETER, ((FormParam) a).value()); } else if (a instanceof MatrixParam) { return new ParameterInfo(Location.MATRIX_PARAMETER, ((MatrixParam) a).value()); } } return new ParameterInfo(Location.REQUEST_BODY, node.getName()); } } return new ParameterInfo(Location.UNKNOWN, node.getName()); }
Example #5
Source File: AnnotationUtils.java From cxf with Apache License 2.0 | 6 votes |
public static String getAnnotationValue(Annotation a) { String value = null; if (a.annotationType() == PathParam.class) { value = ((PathParam)a).value(); } else if (a.annotationType() == QueryParam.class) { value = ((QueryParam)a).value(); } else if (a.annotationType() == MatrixParam.class) { value = ((MatrixParam)a).value(); } else if (a.annotationType() == HeaderParam.class) { value = ((HeaderParam)a).value(); } else if (a.annotationType() == CookieParam.class) { value = ((CookieParam)a).value(); } else if (a.annotationType() == FormParam.class) { value = ((FormParam)a).value(); } return value; }
Example #6
Source File: JaxrsApplicationParser.java From typescript-generator with MIT License | 6 votes |
private MethodParameterModel getEntityParameter(Class<?> resourceClass, Method method, List<Pair<Parameter, Type>> parameters) { for (Pair<Parameter, Type> pair : parameters) { if (!Utils.hasAnyAnnotation(annotationClass -> pair.getValue1().getAnnotation(annotationClass), Arrays.asList( MatrixParam.class, QueryParam.class, PathParam.class, CookieParam.class, HeaderParam.class, Suspended.class, Context.class, FormParam.class, BeanParam.class ))) { final Type resolvedType = GenericsResolver.resolveType(resourceClass, pair.getValue2(), method.getDeclaringClass()); return new MethodParameterModel(pair.getValue1().getName(), resolvedType); } } return null; }
Example #7
Source File: MyResource.java From resteasy-examples with Apache License 2.0 | 6 votes |
@Path("foo/{param}-{other}") @GET public String getFooParam(@PathParam("param") String param, @PathParam("other") String other, @QueryParam("q") String q, @CookieParam("c") String c, @HeaderParam("h") String h, @MatrixParam("m") String m, @Context UriInfo ignore) { StringBuffer buf = new StringBuffer(); buf.append("param").append("=").append(param).append(";"); buf.append("other").append("=").append(other).append(";"); buf.append("q").append("=").append(q).append(";"); buf.append("c").append("=").append(c).append(";"); buf.append("h").append("=").append(h).append(";"); buf.append("m").append("=").append(m).append(";"); return buf.toString(); }
Example #8
Source File: MvcConverterProvider.java From krazo with Apache License 2.0 | 6 votes |
private static String getParamName(Annotation[] annotations) { for (Annotation annotation : annotations) { if (annotation instanceof QueryParam) { return ((QueryParam) annotation).value(); } if (annotation instanceof PathParam) { return ((PathParam) annotation).value(); } if (annotation instanceof FormParam) { return ((FormParam) annotation).value(); } if (annotation instanceof MatrixParam) { return ((MatrixParam) annotation).value(); } if (annotation instanceof CookieParam) { return ((CookieParam) annotation).value(); } } return null; }
Example #9
Source File: ConstraintViolationMetadata.java From krazo with Apache License 2.0 | 6 votes |
public Optional<String> getParamName() { for (Annotation annotation : annotations) { if (annotation instanceof QueryParam) { return Optional.of(((QueryParam) annotation).value()); } if (annotation instanceof PathParam) { return Optional.of(((PathParam) annotation).value()); } if (annotation instanceof FormParam) { return Optional.of(((FormParam) annotation).value()); } if (annotation instanceof MatrixParam) { return Optional.of(((MatrixParam) annotation).value()); } if (annotation instanceof CookieParam) { return Optional.of(((CookieParam) annotation).value()); } } return Optional.empty(); }
Example #10
Source File: MyResource.java From resteasy-examples with Apache License 2.0 | 6 votes |
@Path("foo/{param}-{other}") @PUT public String putFooParam(@PathParam("param") String param, @PathParam("other") String other, @QueryParam("q") String q, @CookieParam("c") String c, @HeaderParam("h") String h, @MatrixParam("m") String m, String entity, @Context UriInfo ignore) { StringBuffer buf = new StringBuffer(); buf.append("param").append("=").append(param).append(";"); buf.append("other").append("=").append(other).append(";"); buf.append("q").append("=").append(q).append(";"); buf.append("c").append("=").append(c).append(";"); buf.append("h").append("=").append(h).append(";"); buf.append("m").append("=").append(m).append(";"); buf.append("entity").append("=").append(entity).append(";"); return buf.toString(); }
Example #11
Source File: BookStore.java From cxf with Apache License 2.0 | 5 votes |
@PUT @Path("books/{bookid}") @Description("Update the book") public void addBook(@PathParam("id") int id, @PathParam("bookid") int bookId, @MatrixParam("mid") int matrixId, Book b) { }
Example #12
Source File: POST_Related_IT.java From agrest with Apache License 2.0 | 5 votes |
@POST @Path("e17/e18s") public DataResponse<E18> createOrUpdateE18s( @Context UriInfo uriInfo, @MatrixParam("parentId1") Integer parentId1, @MatrixParam("parentId2") Integer parentId2, String targetData) { Map<String, Object> parentIds = new HashMap<>(); parentIds.put(E17.ID1_PK_COLUMN, parentId1); parentIds.put(E17.ID2_PK_COLUMN, parentId2); return Ag.createOrUpdate(E18.class, config).toManyParent(E17.class, parentIds, E17.E18S).uri(uriInfo) .syncAndSelect(targetData); }
Example #13
Source File: ParameterHelperTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@Test public void annotationsThatMightBeAppliedToResourceFields() { assertEquals(7, ParameterHelper.RESOURCE_FIELDS_ANNOTATIONS.size()); assertThat(ParameterHelper.RESOURCE_FIELDS_ANNOTATIONS, hasItems(CookieParam.class.getName(), Context.class.getName(), Property.class.getName(), QueryParam.class.getName(), PathParam.class.getName(), MatrixParam.class.getName(), HeaderParam.class.getName()) ); }
Example #14
Source File: ParameterResolverFactoryTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@DataProvider public static Object[][] supportedAnnotations() { return new Object[][]{ {annotationOfType(CookieParam.class), CookieParameterResolver.class}, {annotationOfType(Context.class), ContextParameterResolver.class}, {annotationOfType(FormParam.class), FormParameterResolver.class}, {annotationOfType(HeaderParam.class), HeaderParameterResolver.class}, {annotationOfType(MatrixParam.class), MatrixParameterResolver.class}, {annotationOfType(PathParam.class), PathParameterResolver.class}, {annotationOfType(QueryParam.class), QueryParameterResolver.class}, {annotationOfType(Property.class), PropertyResolver.class} }; }
Example #15
Source File: AnnotationUtils.java From cxf with Apache License 2.0 | 5 votes |
private static Set<Class<?>> initParamAnnotationClasses() { Set<Class<?>> classes = new HashSet<>(); classes.add(PathParam.class); classes.add(QueryParam.class); classes.add(MatrixParam.class); classes.add(HeaderParam.class); classes.add(CookieParam.class); classes.add(FormParam.class); classes.add(BeanParam.class); return classes; }
Example #16
Source File: BookStore.java From cxf with Apache License 2.0 | 5 votes |
@GET @Path("/segment/matrix-middle") public Book getBookByMatrixParamsMiddle(@MatrixParam("first") String s1, @MatrixParam("second") String s2) throws Exception { return doGetBook(s1 + s2); }
Example #17
Source File: BookSubresource.java From cxf with Apache License 2.0 | 5 votes |
@POST @Path("/subresource4/{id}/{name}") @Produces("application/xml") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Book getTheBook4(@PathParam("") Book bookPath, @QueryParam("") Book bookQuery, @MatrixParam("") Book matrixBook, @FormParam("") Book formBook) throws BookNotFoundFault;
Example #18
Source File: ParameterScanTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@GET @Path("/anotherpathsegment/reloaded/") @Produces(MediaType.APPLICATION_JSON) public Widget get(@MatrixParam("m1") @DefaultValue("default-m1") String m1, @MatrixParam("m2") @Size(min = 20) String m2) { return null; }
Example #19
Source File: JaxrsApplicationTest.java From typescript-generator with MIT License | 5 votes |
@POST public void setI( @MatrixParam("") String matrixParam, @QueryParam("") String queryParam, @PathParam("") String pathParam, @CookieParam("") String cookieParam, @Suspended AsyncResponse suspendedParam, @HeaderParam("") String headerParam, @Context String context, @FormParam("") String formParam, I entityI) { }
Example #20
Source File: BookStore.java From cxf with Apache License 2.0 | 5 votes |
@GET @Path("/segment/matrix-list") public Book getBookByMatrixListParams(@MatrixParam("first") List<String> list) throws Exception { if (list.size() != 2) { throw new RuntimeException(); } return doGetBook(list.get(0) + list.get(1)); }
Example #21
Source File: ParameterResolverFactory.java From everrest with Eclipse Public License 2.0 | 5 votes |
/** * Create parameter resolver for supplied annotation. * * @param annotation * JAX-RS annotation * @return ParameterResolver */ public ParameterResolver createParameterResolver(Annotation annotation) { final Class annotationType = annotation.annotationType(); if (annotationType == CookieParam.class) { return new CookieParameterResolver((CookieParam)annotation, new TypeProducerFactory()); } if (annotationType == Context.class) { return new ContextParameterResolver(); } if (annotationType == FormParam.class) { return new FormParameterResolver((FormParam)annotation, new TypeProducerFactory()); } if (annotationType == HeaderParam.class) { return new HeaderParameterResolver((HeaderParam)annotation, new TypeProducerFactory()); } if (annotationType == MatrixParam.class) { return new MatrixParameterResolver((MatrixParam)annotation, new TypeProducerFactory()); } if (annotationType == PathParam.class) { return new PathParameterResolver((PathParam)annotation, new TypeProducerFactory()); } if (annotationType == QueryParam.class) { return new QueryParameterResolver((QueryParam)annotation, new TypeProducerFactory()); } if (annotationType == Property.class) { return new PropertyResolver((Property)annotation); } throw new IllegalArgumentException(String.format("Unsupported annotation %s", annotationType)); }
Example #22
Source File: FieldInjectorImpl.java From everrest with Eclipse Public License 2.0 | 5 votes |
@Override public void inject(Object resource, ApplicationContext context) { try { Object value = null; if (annotation != null) { value = parameterResolverFactory.createParameterResolver(annotation).resolve(this, context); } else { DependencySupplier dependencies = context.getDependencySupplier(); if (dependencies != null) { value = dependencies.getInstance(this); } } if (value != null) { if (setter != null) { setter.invoke(resource, value); } else { if (!Modifier.isPublic(field.getModifiers())) { field.setAccessible(true); } field.set(resource, value); } } } catch (Exception e) { if (annotation != null) { Class<?> annotationType = annotation.annotationType(); if (annotationType == PathParam.class || annotationType == QueryParam.class || annotationType == MatrixParam.class) { throw new WebApplicationException(e, Response.status(NOT_FOUND).build()); } throw new WebApplicationException(e, Response.status(BAD_REQUEST).build()); } throw new WebApplicationException(e, Response.status(INTERNAL_SERVER_ERROR).build()); } }
Example #23
Source File: ConstructorDescriptorImplTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void mockParameterResolverFactory() { parameterResolverFactory = mock(ParameterResolverFactory.class); pathParameterResolver = mock(ParameterResolver.class); queryParameterResolver = mock(ParameterResolver.class); matrixParameterResolver = mock(ParameterResolver.class); cookieParameterResolver = mock(ParameterResolver.class); headerParameterResolver = mock(ParameterResolver.class); when(parameterResolverFactory.createParameterResolver(isA(PathParam.class))).thenReturn(pathParameterResolver); when(parameterResolverFactory.createParameterResolver(isA(QueryParam.class))).thenReturn(queryParameterResolver); when(parameterResolverFactory.createParameterResolver(isA(MatrixParam.class))).thenReturn(matrixParameterResolver); when(parameterResolverFactory.createParameterResolver(isA(CookieParam.class))).thenReturn(cookieParameterResolver); when(parameterResolverFactory.createParameterResolver(isA(HeaderParam.class))).thenReturn(headerParameterResolver); }
Example #24
Source File: BookStore.java From cxf with Apache License 2.0 | 5 votes |
@GET @Path("/segment/matrix") public Book getBookByMatrixParams(@MatrixParam("first") String s1, @MatrixParam("second") String s2) throws Exception { return doGetBook(s1 + s2); }
Example #25
Source File: GET_Related_IT.java From agrest with Apache License 2.0 | 5 votes |
@GET @Path("e17/e18s") public DataResponse<E18> getChildren( @Context UriInfo uriInfo, @MatrixParam("parentId1") Integer parentId1, @MatrixParam("parentId2") Integer parentId2) { Map<String, Object> parentIds = new HashMap<>(); parentIds.put(E17.ID1_PK_COLUMN, parentId1); parentIds.put(E17.ID2_PK_COLUMN, parentId2); return Ag.select(E18.class, config).parent(E17.class, parentIds, E17.E18S.getName()).uri(uriInfo).get(); }
Example #26
Source File: AutoRestGwtProcessor.java From autorest with Apache License 2.0 | 5 votes |
public boolean isParam(VariableElement a) { return a.getAnnotation(CookieParam.class) != null || a.getAnnotation(FormParam.class) != null || a.getAnnotation(HeaderParam.class) != null || a.getAnnotation(MatrixParam.class) != null || a.getAnnotation(PathParam.class) != null || a.getAnnotation(QueryParam.class) != null; }
Example #27
Source File: CarResource.java From resteasy-examples with Apache License 2.0 | 5 votes |
@GET @Path("/matrix/{make}/{model}/{year}") @Produces("text/plain") public String getFromMatrixParam(@PathParam("make") String make, @PathParam("model") PathSegment car, @MatrixParam("color") Color color, @PathParam("year") String year) { return "A " + color + " " + year + " " + make + " " + car.getPath(); }
Example #28
Source File: ParameterHelperTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@Test public void annotationsThatMightBeAppliedToResourceConstructorParameters() { assertEquals(7, ParameterHelper.RESOURCE_CONSTRUCTOR_PARAMETER_ANNOTATIONS.size()); assertThat(ParameterHelper.RESOURCE_CONSTRUCTOR_PARAMETER_ANNOTATIONS, hasItems(CookieParam.class.getName(), Context.class.getName(), Property.class.getName(), QueryParam.class.getName(), PathParam.class.getName(), MatrixParam.class.getName(), HeaderParam.class.getName()) ); }
Example #29
Source File: ConstructorDescriptorImplTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
public Resource(@PathParam("x") String pathParam, @Encoded @QueryParam("q") String queryParam, @MatrixParam("m") String matrixParam, @CookieParam("c") String cookieParam, @DefaultValue("default") @HeaderParam("h") String headerParam) { this.pathParam = pathParam; this.queryParam = queryParam; this.matrixParam = matrixParam; this.cookieParam = cookieParam; this.headerParam = headerParam; }
Example #30
Source File: TestMatrixParamRest.java From rest.vertx with Apache License 2.0 | 5 votes |
@GET @Path("extract/{param}") public String add(@PathParam("param") String param, @MatrixParam("one") int one, @MatrixParam("two") int two) { int result = one + two; return param + "=" + result; }