From commits-return-5449-archive-asf-public=cust-asf.ponee.io@juneau.apache.org Wed Aug 1 21:51:49 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 17293180634 for ; Wed, 1 Aug 2018 21:51:48 +0200 (CEST) Received: (qmail 4040 invoked by uid 500); 1 Aug 2018 19:51:48 -0000 Mailing-List: contact commits-help@juneau.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@juneau.apache.org Delivered-To: mailing list commits@juneau.apache.org Received: (qmail 4031 invoked by uid 99); 1 Aug 2018 19:51:48 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Aug 2018 19:51:48 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 99FDA807EC; Wed, 1 Aug 2018 19:51:47 +0000 (UTC) Date: Wed, 01 Aug 2018 19:51:47 +0000 To: "commits@juneau.apache.org" Subject: [juneau] branch master updated: Refactor RestMethodParam to include method parameter index. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153315310757.12750.17684488678993116670@gitbox.apache.org> From: jamesbognar@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: juneau X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 64e8b74ed760872189133c377b88497854949d1c X-Git-Newrev: d298a5af8c0ff892fd2b811124de9c69b4b0cc8d X-Git-Rev: d298a5af8c0ff892fd2b811124de9c69b4b0cc8d X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. jamesbognar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/juneau.git The following commit(s) were added to refs/heads/master by this push: new d298a5a Refactor RestMethodParam to include method parameter index. d298a5a is described below commit d298a5af8c0ff892fd2b811124de9c69b4b0cc8d Author: JamesBognar AuthorDate: Wed Aug 1 15:51:29 2018 -0400 Refactor RestMethodParam to include method parameter index. --- .../java/org/apache/juneau/rest/RestContext.java | 14 ++++----- .../org/apache/juneau/rest/RestMethodParam.java | 14 ++++++--- .../org/apache/juneau/rest/RestParamDefaults.java | 36 +++++++++++----------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java index ddf7748..aee7dd2 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java @@ -4316,23 +4316,23 @@ public final class RestContext extends BeanContext { if (hasAnnotation(Header.class, method, i)) { s = HttpPartSchema.create(Header.class, method, i); - rp[i] = new RestParamDefaults.HeaderObject(method, s, t, ps); + rp[i] = new RestParamDefaults.HeaderObject(method, i, s, t, ps); } else if (hasAnnotation(Query.class, method, i)) { s = HttpPartSchema.create(Query.class, method, i); - rp[i] = new RestParamDefaults.QueryObject(method, s, t, ps); + rp[i] = new RestParamDefaults.QueryObject(method, i, s, t, ps); } else if (hasAnnotation(FormData.class, method, i)) { s = HttpPartSchema.create(FormData.class, method, i); - rp[i] = new RestParamDefaults.FormDataObject(method, s, t, ps); + rp[i] = new RestParamDefaults.FormDataObject(method, i, s, t, ps); } else if (hasAnnotation(Path.class, method, i)) { s = HttpPartSchema.create(Path.class, method, i); rp[i] = new RestParamDefaults.PathObject(method, i, s, t, ps); } else if (hasAnnotation(Body.class, method, i)) { s = HttpPartSchema.create(Body.class, method, i); - rp[i] = new RestParamDefaults.BodyObject(method, s, t, ps); + rp[i] = new RestParamDefaults.BodyObject(method, i, s, t, ps); } else if (hasAnnotation(RequestBean.class, method, i)) { RequestBeanMeta rbm = RequestBeanMeta.create(method, i, ps); - rp[i] = new RestParamDefaults.RequestBeanObject(method, rbm, t); + rp[i] = new RestParamDefaults.RequestBeanObject(method, i, rbm, t); } else if (hasAnnotation(Response.class, method, i) || hasAnnotation(Response.class, Value.getValueType(method, i))) { s = HttpPartSchema.create(Response.class, method, i); @@ -4349,10 +4349,10 @@ public final class RestContext extends BeanContext { } else if (hasAnnotation(HasFormData.class, method, i)) { s = HttpPartSchema.create(HasFormData.class, method, i); - rp[i] = new RestParamDefaults.HasFormDataObject(method, s, t); + rp[i] = new RestParamDefaults.HasFormDataObject(method, i, s, t); } else if (hasAnnotation(HasQuery.class, method, i)) { s = HttpPartSchema.create(HasQuery.class, method, i); - rp[i] = new RestParamDefaults.HasQueryObject(method, s, t); + rp[i] = new RestParamDefaults.HasQueryObject(method, i, s, t); } else if (hasAnnotation(org.apache.juneau.rest.annotation.Method.class, method, i)) { rp[i] = new RestParamDefaults.MethodObject(method, t); diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodParam.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodParam.java index b4b07c8..2942e53 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodParam.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodParam.java @@ -115,6 +115,7 @@ public abstract class RestMethodParam { final RestParamType paramType; final Method method; + final int index; final String name; final Type type; final Class c; @@ -125,15 +126,17 @@ public abstract class RestMethodParam { * * @param paramType The Swagger parameter type. * @param method The method on which the parameter resides. + * @param index The method parameter index. * @param name * The parameter name. * Can be null if parameter doesn't have a name (e.g. the request body). * @param type The object type to convert the parameter to. * @param api Swagger metadata. */ - protected RestMethodParam(RestParamType paramType, Method method, String name, Type type, ObjectMap api) { + protected RestMethodParam(RestParamType paramType, Method method, int index, String name, Type type, ObjectMap api) { this.paramType = paramType; this.method = method; + this.index = index; this.name = name; this.type = type; this.c = type instanceof Class ? (Class)type : type instanceof ParameterizedType ? (Class)((ParameterizedType)type).getRawType() : null; @@ -147,7 +150,7 @@ public abstract class RestMethodParam { * @param type The object type to convert the parameter to. */ protected RestMethodParam(RestParamType paramType, Type type) { - this(paramType, null, null, type, ObjectMap.EMPTY_MAP); + this(paramType, null, -1, null, type, ObjectMap.EMPTY_MAP); } /** @@ -160,7 +163,7 @@ public abstract class RestMethodParam { * @param type The object type to convert the parameter to. */ protected RestMethodParam(RestParamType paramType, String name, Type type) { - this(paramType, null, name, type, ObjectMap.EMPTY_MAP); + this(paramType, null, -1, name, type, ObjectMap.EMPTY_MAP); } /** @@ -168,13 +171,14 @@ public abstract class RestMethodParam { * * @param paramType The Swagger parameter type. * @param method The method on which the parameter resides. + * @param index The method parameter index. * @param name * The parameter name. * Can be null if parameter doesn't have a name (e.g. the request body). * @param type The object type to convert the parameter to. */ - protected RestMethodParam(RestParamType paramType, Method method, String name, Type type) { - this(paramType, method, name, type, ObjectMap.EMPTY_MAP); + protected RestMethodParam(RestParamType paramType, Method method, int index, String name, Type type) { + this(paramType, method, index, name, type, ObjectMap.EMPTY_MAP); } /** diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java index a14060f..52618b7 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java @@ -553,7 +553,7 @@ class RestParamDefaults { private final HttpPartSchema schema; protected PathObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { - super(PATH, m, s.getName(), t, s.getApi()); + super(PATH, m, i, s.getName(), t, s.getApi()); this.schema = HttpPartSchema.create(Path.class, m, i); this.partParser = createPartParser(schema.getParser(), ps); @@ -571,8 +571,8 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected BodyObject(Method m, HttpPartSchema s, Type t, PropertyStore ps) { - super(BODY, m, null, t, s.getApi()); + protected BodyObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { + super(BODY, m, i, null, t, s.getApi()); this.partParser = s.isUsePartParser() ? createPartParser(s.getParser(), ps) : null; this.schema = s; } @@ -587,8 +587,8 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected HeaderObject(Method m, HttpPartSchema s, Type t, PropertyStore ps) { - super(HEADER, m, s.getName(), t, s.getApi()); + protected HeaderObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { + super(HEADER, m, i, s.getName(), t, s.getApi()); this.partParser = createPartParser(s.getParser(), ps); this.schema = s; @@ -605,8 +605,8 @@ class RestParamDefaults { static final class RequestBeanObject extends RestMethodParam { private final RequestBeanMeta requestBeanMeta; - protected RequestBeanObject(Method m, RequestBeanMeta rbm, Type t) { - super(RESPONSE_BODY, m, null, t, null); + protected RequestBeanObject(Method m, int i, RequestBeanMeta rbm, Type t) { + super(RESPONSE_BODY, m, i, null, t, null); this.requestBeanMeta = rbm; } @@ -620,7 +620,7 @@ class RestParamDefaults { final ResponsePartMeta rpm; protected ResponseHeaderObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { - super(RESPONSE_HEADER, m, s.getName(), t, HttpPartSchema.getApiCodeMap(s, 200)); + super(RESPONSE_HEADER, m, i, s.getName(), t, HttpPartSchema.getApiCodeMap(s, 200)); this.rpm = new ResponsePartMeta(HttpPartType.HEADER, s, createPartSerializer(s.getSerializer(), ps)); if (isEmpty(rpm.getSchema().getName())) @@ -654,7 +654,7 @@ class RestParamDefaults { final ResponsePartMeta rpm; protected ResponseBodyObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { - super(RESPONSE_BODY, m, s.getName(), t, HttpPartSchema.getApiCodeMap(s, 200)); + super(RESPONSE_BODY, m, i, s.getName(), t, HttpPartSchema.getApiCodeMap(s, 200)); this.rpm = new ResponsePartMeta(HttpPartType.BODY, s, createPartSerializer(s.getSerializer(), ps)); if (getTypeClass() != Value.class) @@ -683,7 +683,7 @@ class RestParamDefaults { final ResponseBeanMeta rbm; protected ResponseBeanObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { - super(RESPONSE, m, s.getName(), t, HttpPartSchema.getApiCodeMap(s, 200)); + super(RESPONSE, m, i, s.getName(), t, HttpPartSchema.getApiCodeMap(s, 200)); this.rbm = ResponseBeanMeta.create(m.getParameterTypes()[i], ps); if (getTypeClass() != Value.class) throw new InternalServerError("Invalid type {0} specified with @Response annotation. It must be Value.", type); @@ -748,8 +748,8 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected FormDataObject(Method m, HttpPartSchema s, Type t, PropertyStore ps) { - super(FORM_DATA, m, s.getName(), t, s.getApi()); + protected FormDataObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { + super(FORM_DATA, m, i, s.getName(), t, s.getApi()); this.partParser = createPartParser(s.getParser(), ps); this.schema = s; this.multiPart = s.getCollectionFormat() == HttpPartSchema.CollectionFormat.MULTI; @@ -773,8 +773,8 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected QueryObject(Method m, HttpPartSchema s, Type t, PropertyStore ps) { - super(QUERY, m, s.getName(), t, s.getApi()); + protected QueryObject(Method m, int i, HttpPartSchema s, Type t, PropertyStore ps) { + super(QUERY, m, i, s.getName(), t, s.getApi()); this.partParser = createPartParser(s.getParser(), ps); this.schema = s; this.multiPart = s.getCollectionFormat() == HttpPartSchema.CollectionFormat.MULTI; @@ -795,8 +795,8 @@ class RestParamDefaults { static final class HasFormDataObject extends RestMethodParam { - protected HasFormDataObject(Method m, HttpPartSchema s, Type t) throws ServletException { - super(FORM_DATA, m, s.getName(), t); + protected HasFormDataObject(Method m, int i, HttpPartSchema s, Type t) throws ServletException { + super(FORM_DATA, m, i, s.getName(), t); if (t != Boolean.class && t != boolean.class) throw new RestServletException("Use of @HasForm annotation on parameter that is not a boolean on method ''{0}''", m); } @@ -810,8 +810,8 @@ class RestParamDefaults { static final class HasQueryObject extends RestMethodParam { - protected HasQueryObject(Method m, HttpPartSchema s, Type t) throws ServletException { - super(QUERY, m, s.getName(), t); + protected HasQueryObject(Method m, int i, HttpPartSchema s, Type t) throws ServletException { + super(QUERY, m, i, s.getName(), t); if (t != Boolean.class && t != boolean.class) throw new RestServletException("Use of @HasQuery annotation on parameter that is not a boolean on method ''{0}''", m); }