Java Code Examples for javax.ws.rs.PathParam#value()
The following examples show how to use
javax.ws.rs.PathParam#value() .
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: AnnotationHelper.java From proteus with Apache License 2.0 | 6 votes |
public static PathParam createPathParam(Parameter parameter) { return new PathParam() { @Override public String value() { PathParam annotation = parameter.getAnnotation(PathParam.class); if (annotation != null) { return annotation.value(); } return parameter.getName(); } @Override public Class<? extends Annotation> annotationType() { return PathParam.class; } }; }
Example 2
Source File: Handler.java From greenbeans with Apache License 2.0 | 6 votes |
private void compileParameters(AnnotatedType[] annotatedParameterTypes, Annotation[][] annotations) { ImmutableList.Builder<String> parameterOrderBuilder = ImmutableList.builder(); ImmutableMap.Builder<String, Type> nameToTypeBuilder = ImmutableMap.builder(); for (int x = 0; x < annotatedParameterTypes.length; ++x) { AnnotatedType annotatedType = annotatedParameterTypes[x]; PathParam pathParam = getPathParam(annotations[x]); String name; Type type; if (pathParam != null) { name = pathParam.value(); type = annotatedType.getType(); } else { name = NAME_ENTITY; type = annotatedType.getType(); } parameterOrderBuilder.add(name); nameToTypeBuilder.put(name, type); } parameterOrder = parameterOrderBuilder.build(); parameterNameToType = nameToTypeBuilder.build(); }
Example 3
Source File: RestUrlParserTest.java From cloudbreak with Apache License 2.0 | 5 votes |
private String replacePathParamsWithExamples(Method method, String methodPath) { for (Parameter parameter : method.getParameters()) { PathParam pathParam = AnnotationUtils.findAnnotation(parameter, PathParam.class); if (pathParam != null) { String pathParamValue = pathParam.value(); Class<?> parameterType = parameter.getType(); if (Long.class.equals(parameterType)) { methodPath = "workspaceId".equals(pathParamValue) ? methodPath.replace('{' + pathParamValue + '}', WORKSPACE_ID) : methodPath.replace('{' + pathParamValue + '}', RESOURCE_ID); } else { if (methodPath.startsWith("/v4/workspaces")) { methodPath = methodPath.replace('{' + pathParamValue + '}', WORKSPACE_NAME); } else if (methodPath.startsWith("/autoscale/stack")) { methodPath = methodPath.replace('{' + pathParamValue + '}', RESOURCE_CRN); } else if (pathParam.value().equals(NAME)) { methodPath = methodPath.replace('{' + pathParamValue + '}', RESOURCE_NAME); } else if (pathParam.value().equals(CRN)) { methodPath = methodPath.replace('{' + pathParamValue + '}', RESOURCE_CRN); } else { methodPath = methodPath.replace('{' + pathParamValue + '}', RESOURCE_NAME); } } } } return methodPath; }
Example 4
Source File: PathParamAnnotationProcessor.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Override public String getParameterName(PathParam parameterAnnotation) { return parameterAnnotation.value(); }
Example 5
Source File: ResourceUtils.java From cxf with Apache License 2.0 | 4 votes |
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); }