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 b921e47 New org.apache.juneau.reflect package. b921e47 is described below commit b921e47c2c6eacb29d8d5635bd6e504e8ec64040 Author: JamesBognar <jamesbog...@apache.org> AuthorDate: Sun Mar 31 21:06:25 2019 -0400 New org.apache.juneau.reflect package. --- .../juneau/httppart/HttpPartSchemaTest_Body.java | 4 +- .../httppart/HttpPartSchemaTest_FormData.java | 4 +- .../juneau/httppart/HttpPartSchemaTest_Header.java | 4 +- .../juneau/httppart/HttpPartSchemaTest_Path.java | 4 +- .../juneau/httppart/HttpPartSchemaTest_Query.java | 4 +- .../HttpPartSchemaTest_ResponseHeader.java | 4 +- .../apache/juneau/reflection/ClassInfoTest.java | 6 +-- .../apache/juneau/reflection/MethodInfoTest.java | 4 +- .../org/apache/juneau/httppart/HttpPartSchema.java | 2 +- .../juneau/httppart/HttpPartSchemaBuilder.java | 4 +- .../juneau/httppart/bean/RequestBeanMeta.java | 6 +-- .../juneau/httppart/bean/ResponseBeanMeta.java | 4 +- .../org/apache/juneau/internal/ClassUtils.java | 53 ---------------------- .../org/apache/juneau/internal/StringUtils.java | 3 +- .../org/apache/juneau/reflect/ConstructorInfo.java | 10 ---- .../org/apache/juneau/reflect/ExecutableInfo.java | 10 ++-- .../java/org/apache/juneau/reflect/FieldInfo.java | 9 ---- .../java/org/apache/juneau/reflect/MethodInfo.java | 41 ++++++----------- .../{MethodParamInfo.java => ParamInfo.java} | 32 +++---------- .../juneau/rest/client/remote/RemoteMethodArg.java | 2 +- .../rest/client/remote/RemoteMethodMeta.java | 2 +- .../java/org/apache/juneau/rest/RestContext.java | 2 +- .../org/apache/juneau/rest/RestMethodParam.java | 14 +++--- .../org/apache/juneau/rest/RestParamDefaults.java | 43 +++++++++--------- .../org/apache/juneau/rest/SwaggerGenerator.java | 4 +- 25 files changed, 86 insertions(+), 189 deletions(-) diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Body.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Body.java index 50857fa..223daed 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Body.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Body.java @@ -74,7 +74,7 @@ public class HttpPartSchemaTest_Body { @Test public void a03_basic_onParameter() throws Exception { - MethodParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Body.class, mpi).noValidate().build(); assertTrue(s.isRequired()); } @@ -95,7 +95,7 @@ public class HttpPartSchemaTest_Body { @Test public void a04_basic_onParameterAndClass() throws Exception { - MethodParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A02.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A02.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Body.class, mpi).noValidate().build(); assertTrue(s.isRequired()); } diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_FormData.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_FormData.java index 393e5ff..6c0c14a 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_FormData.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_FormData.java @@ -136,7 +136,7 @@ public class HttpPartSchemaTest_FormData { @Test public void a03_basic_onParameter() throws Exception { - MethodParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(FormData.class, mpi).noValidate().build(); assertEquals("x", s.getName()); assertEquals(HttpPartSchema.Type.NUMBER, s.getType()); @@ -193,7 +193,7 @@ public class HttpPartSchemaTest_FormData { @Test public void a04_basic_onParameterAndClass() throws Exception { - MethodParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(FormData.class, mpi).noValidate().build(); assertEquals("y", s.getName()); assertEquals(HttpPartSchema.Type.INTEGER, s.getType()); diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Header.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Header.java index c5a4bbc..a8a40d9 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Header.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Header.java @@ -136,7 +136,7 @@ public class HttpPartSchemaTest_Header { @Test public void a03_basic_onParameter() throws Exception { - MethodParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Header.class, mpi).noValidate().build(); assertEquals("x", s.getName()); assertEquals(HttpPartSchema.Type.NUMBER, s.getType()); @@ -193,7 +193,7 @@ public class HttpPartSchemaTest_Header { @Test public void a04_basic_onParameterAndClass() throws Exception { - MethodParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Header.class, mpi).noValidate().build(); assertEquals("y", s.getName()); assertEquals(HttpPartSchema.Type.INTEGER, s.getType()); diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Path.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Path.java index 82dfeed..67fc14a 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Path.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Path.java @@ -118,7 +118,7 @@ public class HttpPartSchemaTest_Path { @Test public void a03_basic_onParameter() throws Exception { - MethodParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Path.class, mpi).noValidate().build(); assertEquals("x", s.getName()); assertEquals(HttpPartSchema.Type.NUMBER, s.getType()); @@ -163,7 +163,7 @@ public class HttpPartSchemaTest_Path { @Test public void a04_basic_onParameterAndClass() throws Exception { - MethodParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Path.class, mpi).noValidate().build(); assertEquals("y", s.getName()); assertEquals(HttpPartSchema.Type.INTEGER, s.getType()); diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Query.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Query.java index 41d1cef..8c5e750 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Query.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_Query.java @@ -136,7 +136,7 @@ public class HttpPartSchemaTest_Query { @Test public void a03_basic_onParameter() throws Exception { - MethodParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Query.class, mpi).noValidate().build(); assertEquals("x", s.getName()); assertEquals(HttpPartSchema.Type.NUMBER, s.getType()); @@ -193,7 +193,7 @@ public class HttpPartSchemaTest_Query { @Test public void a04_basic_onParameterAndClass() throws Exception { - MethodParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(Query.class, mpi).noValidate().build(); assertEquals("y", s.getName()); assertEquals(HttpPartSchema.Type.INTEGER, s.getType()); diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_ResponseHeader.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_ResponseHeader.java index 2840075..4c6c1bc 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_ResponseHeader.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/HttpPartSchemaTest_ResponseHeader.java @@ -130,7 +130,7 @@ public class HttpPartSchemaTest_ResponseHeader { @Test public void a03_basic_onParameter() throws Exception { - MethodParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A03.class.getMethod("a", String.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(ResponseHeader.class, mpi).noValidate().build(); assertEquals("x", s.getName()); assertEquals(HttpPartSchema.Type.NUMBER, s.getType()); @@ -183,7 +183,7 @@ public class HttpPartSchemaTest_ResponseHeader { @Test public void a04_basic_onParameterAndClass() throws Exception { - MethodParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); + ParamInfo mpi = getMethodInfo(A04.class.getMethod("a", A01.class)).getParam(0); HttpPartSchema s = HttpPartSchema.create().apply(ResponseHeader.class, mpi).noValidate().build(); assertEquals("y", s.getName()); assertEquals(HttpPartSchema.Type.INTEGER, s.getType()); diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java index 7082eff..40714b7 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java @@ -78,11 +78,11 @@ public class ClassInfoTest { if (t instanceof ClassInfo) return ((ClassInfo)t).getSimpleName(); if (t instanceof MethodInfo) - return ((MethodInfo)t).getDeclaringClass().getSimpleName() + '.' + ((MethodInfo)t).getLabel(); + return ((MethodInfo)t).getDeclaringClass().getSimpleName() + '.' + ((MethodInfo)t).getShortName(); if (t instanceof ConstructorInfo) - return ((ConstructorInfo)t).getLabel(); + return ((ConstructorInfo)t).getShortName(); if (t instanceof FieldInfo) - return ((FieldInfo)t).getDeclaringClass().getSimpleName() + '.' + ((FieldInfo)t).getLabel(); + return ((FieldInfo)t).getDeclaringClass().getSimpleName() + '.' + ((FieldInfo)t).getName(); if (t instanceof A) return "@A(" + ((A)t).value() + ")"; if (t instanceof PA) diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java index 081113d..1f11fba 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java @@ -96,7 +96,7 @@ public class MethodInfoTest { @Test public void getAnnotationsOnParameter() throws Exception { ObjectList l = new ObjectList(); - MethodParamInfo mpi = MethodInfo.of(HA.class.getMethod("doX", HA01.class)).getParam(0); + ParamInfo mpi = MethodInfo.of(HA.class.getMethod("doX", HA01.class)).getParam(0); for (HI1 ia : mpi.getAnnotations(HI1.class)) { l.add(ia.value()); } @@ -122,7 +122,7 @@ public class MethodInfoTest { @Test public void getAnnotationsOnParameterInherited() throws Exception { ObjectList l = new ObjectList(); - MethodParamInfo mpi = MethodInfo.of(HB.class.getMethod("doX", HB01.class)).getParam(0); + ParamInfo mpi = MethodInfo.of(HB.class.getMethod("doX", HB01.class)).getParam(0); for (HI2 ib : mpi.getAnnotations(HI2.class)) { l.add(ib.value()); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java index 22c166e..1137fbe 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java @@ -113,7 +113,7 @@ public class HttpPartSchema { * @param mpi The Java method parameter. * @return The schema information about the parameter. */ - public static HttpPartSchema create(Class<? extends Annotation> c, MethodParamInfo mpi) { + public static HttpPartSchema create(Class<? extends Annotation> c, ParamInfo mpi) { return create().apply(c, mpi).build(); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java index 4a7e73f..6503d4e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java @@ -65,8 +65,8 @@ public class HttpPartSchemaBuilder { return new HttpPartSchema(this); } - HttpPartSchemaBuilder apply(Class<? extends Annotation> c, MethodParamInfo mpi) { - apply(c, mpi.getGenericParameterType()); + HttpPartSchemaBuilder apply(Class<? extends Annotation> c, ParamInfo mpi) { + apply(c, mpi.getParameterType().innerType()); for (Annotation a : mpi.getParameterAnnotations()) if (c.isInstance(a)) apply(a); diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java index 5774392..2318c7f 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java @@ -38,7 +38,7 @@ public class RequestBeanMeta { * <br>Can be <jk>null</jk>. * @return Metadata about the parameter, or <jk>null</jk> if parameter or parameter type not annotated with {@link Request}. */ - public static RequestBeanMeta create(MethodParamInfo mpi, PropertyStore ps) { + public static RequestBeanMeta create(ParamInfo mpi, PropertyStore ps) { if (! mpi.hasAnnotation(Request.class)) return null; return new RequestBeanMeta.Builder(ps).apply(mpi).build(); @@ -90,8 +90,8 @@ public class RequestBeanMeta { this.ps = ps; } - Builder apply(MethodParamInfo mpi) { - return apply(mpi.getParameterType()).apply(mpi.getAnnotation(Request.class)); + Builder apply(ParamInfo mpi) { + return apply(mpi.getParameterType().inner()).apply(mpi.getAnnotation(Request.class)); } Builder apply(Class<?> c) { diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java index e2c6f17..9b5ce6a 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java @@ -85,11 +85,11 @@ public class ResponseBeanMeta { * <br>Can be <jk>null</jk>. * @return Metadata about the class, or <jk>null</jk> if class not annotated with {@link Response}. */ - public static ResponseBeanMeta create(MethodParamInfo mpi, PropertyStore ps) { + public static ResponseBeanMeta create(ParamInfo mpi, PropertyStore ps) { if (! mpi.hasAnnotation(Response.class)) return null; Builder b = new Builder(ps); - b.apply(mpi.getGenericParameterTypeInfo().resolved().innerType()); + b.apply(mpi.getParameterType().resolved().innerType()); for (Response r : mpi.getAnnotations(Response.class)) b.apply(r); return b.build(); diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java index ae77f6d..a915537 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java @@ -334,59 +334,6 @@ public final class ClassUtils { } /** - * Returns a readable representation of the specified method. - * - * <p> - * The format of the string is <js>"full-qualified-class.method-name(parameter-simple-class-names)"</js>. - * - * @param m The method to stringify. - * @return The stringified method. - */ - public static String asString(Method m) { - StringBuilder sb = new StringBuilder(m.getName() + "("); - for (int i = 0; i < m.getParameterTypes().length; i++) { - if (i > 0) - sb.append(","); - sb.append(m.getParameterTypes()[i].getSimpleName()); - } - sb.append(")"); - return sb.toString(); - } - - /** - * Returns a readable representation of the specified method. - * - * <p> - * The format of the string is <js>"full-qualified-class.method-name(parameter-simple-class-names)"</js>. - * - * @param m The method to stringify. - * @return The stringified method. - */ - public static String asString(Constructor<?> m) { - StringBuilder sb = new StringBuilder(m.getDeclaringClass().getSimpleName() + "("); - for (int i = 0; i < m.getParameterTypes().length; i++) { - if (i > 0) - sb.append(","); - sb.append(m.getParameterTypes()[i].getSimpleName()); - } - sb.append(")"); - return sb.toString(); - } - - /** - * Returns a readable representation of the specified field. - * - * <p> - * The format of the string is <js>"full-qualified-class.field-name"</js>. - * - * @param f The field to stringify. - * @return The stringified field. - */ - public static String asString(Field f) { - return f.getName(); - } - - /** * Constructs a new instance of the specified class from the specified string. * * <p> diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java index 40876bf..a734775 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java @@ -32,6 +32,7 @@ import org.apache.juneau.*; import org.apache.juneau.json.*; import org.apache.juneau.parser.*; import org.apache.juneau.parser.ParseException; +import org.apache.juneau.reflect.*; /** * Reusable string utility methods. @@ -2251,7 +2252,7 @@ public final class StringUtils { if (cm.isClass()) return ((Class<?>)o).getName(); if (cm.isMethod()) - return ClassUtils.asString((Method)o); + return MethodInfo.of((Method)o).getShortName(); return o.toString(); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java index 6fed09c..fc3eea7 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java @@ -16,7 +16,6 @@ import java.lang.reflect.*; import org.apache.juneau.*; import org.apache.juneau.annotation.*; -import org.apache.juneau.internal.*; /** * Lightweight utility class for introspecting information about a constructor. @@ -126,13 +125,4 @@ public final class ConstructorInfo extends ExecutableInfo implements Comparable< } return i; } - - /** - * Returns a string representation of this constructor that consists of its name and simple arguments. - * - * @return A string representation of this constructor that consists of its name and simple arguments. - */ - public String getLabel() { - return ClassUtils.asString(c); - } } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java index 9450c96..edcabe5 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java @@ -29,7 +29,7 @@ public abstract class ExecutableInfo { final Executable e; final boolean isConstructor; - private List<MethodParamInfo> params; + private List<ParamInfo> params; private List<ClassInfo> paramTypes, exceptionInfos; private Class<?>[] rawParamTypes, rawExceptionTypes; private Type[] rawGenericParamTypes; @@ -113,11 +113,11 @@ public abstract class ExecutableInfo { * * @return An array of parameter information, never <jk>null</jk>. */ - public final List<MethodParamInfo> getParams() { + public final List<ParamInfo> getParams() { if (params == null) { - List<MethodParamInfo> l = new ArrayList<>(getParamCount()); + List<ParamInfo> l = new ArrayList<>(getParamCount()); for (int i = 0; i < getParamCount(); i++) - l.add(new MethodParamInfo(this, i)); + l.add(new ParamInfo(this, i)); params = Collections.unmodifiableList(l); } return params; @@ -129,7 +129,7 @@ public abstract class ExecutableInfo { * @param index The parameter index. * @return The parameter information, never <jk>null</jk>. */ - public final MethodParamInfo getParam(int index) { + public final ParamInfo getParam(int index) { return getParams().get(index); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java index 88e03f4..3913e27 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java @@ -358,13 +358,4 @@ public final class FieldInfo implements Comparable<FieldInfo> { public String getName() { return f.getName(); } - - /** - * Returns a string representation of this field that consists of its name. - * - * @return A string representation of this field that consists of its name. - */ - public String getLabel() { - return f.getName(); - } } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java index 302c4ec..11d098e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java @@ -31,7 +31,6 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho private ClassInfo returnType; private final Method m; private List<Method> matching; - private String signature; //----------------------------------------------------------------------------------------------------------------- // Instantiation. @@ -284,23 +283,20 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho * @return The methods signature. */ public String getSignature() { - if (signature == null) { - StringBuilder sb = new StringBuilder(128); - sb.append(m.getName()); - Class<?>[] pt = rawParamTypes(); - if (pt.length > 0) { - sb.append('('); - List<MethodParamInfo> mpi = getParams(); - for (int i = 0; i < pt.length; i++) { - if (i > 0) - sb.append(','); - mpi.get(i).getGenericParameterTypeInfo().appendFullName(sb); - } - sb.append(')'); + StringBuilder sb = new StringBuilder(128); + sb.append(m.getName()); + Class<?>[] pt = rawParamTypes(); + if (pt.length > 0) { + sb.append('('); + List<ParamInfo> mpi = getParams(); + for (int i = 0; i < pt.length; i++) { + if (i > 0) + sb.append(','); + mpi.get(i).getParameterType().appendFullName(sb); } - signature = sb.toString(); + sb.append(')'); } - return signature; + return sb.toString(); } /** @@ -393,15 +389,6 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho } /** - * Returns a string representation of this method that consists of its name and simple arguments. - * - * @return A string representation of this method that consists of its name and simple arguments. - */ - public String getLabel() { - return ClassUtils.asString(m); - } - - /** * Returns a readable representation of this method. * * @return A readable representation of this method. @@ -409,11 +396,11 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho public Object getReadableName() { StringBuilder sb = new StringBuilder(128); sb.append(m.getDeclaringClass().getName()).append('.').append(m.getName()).append('('); - List<MethodParamInfo> mpis = getParams(); + List<ParamInfo> mpis = getParams(); for (int i = 0; i < mpis.size(); i++) { if (i > 0) sb.append(','); - mpis.get(i).getGenericParameterTypeInfo().appendFullName(sb); + mpis.get(i).getParameterType().appendFullName(sb); } sb.append(')'); return sb.toString(); diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodParamInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java similarity index 92% rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodParamInfo.java rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java index 7a71774..a7e1682 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodParamInfo.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java @@ -25,7 +25,7 @@ import org.apache.juneau.annotation.*; * Lightweight utility class for introspecting information about a method parameter. */ @BeanIgnore -public final class MethodParamInfo { +public final class ParamInfo { private final ExecutableInfo eInfo; private int index; @@ -41,7 +41,7 @@ public final class MethodParamInfo { * @param eInfo The constructor or method wrapper. * @param index The parameter index. */ - protected MethodParamInfo(ExecutableInfo eInfo, int index) { + protected ParamInfo(ExecutableInfo eInfo, int index) { this.eInfo = eInfo; this.index = index; } @@ -60,8 +60,8 @@ public final class MethodParamInfo { * * @return The method that this parameter belongs to. */ - public Method getMethod() { - return (Method)eInfo.e; + public MethodInfo getMethod() { + return (MethodInfo)eInfo; } /** @@ -69,8 +69,8 @@ public final class MethodParamInfo { * * @return The method that this parameter belongs to. */ - public Constructor<?> getConstructor() { - return (Constructor<?>)eInfo.e; + public ConstructorInfo getConstructor() { + return (ConstructorInfo)eInfo; } /** @@ -78,25 +78,7 @@ public final class MethodParamInfo { * * @return The class type of this parameter. */ - public Class<?> getParameterType() { - return eInfo.getRawParamType(index); - } - - /** - * Returns the generic class type of this parameter. - * - * @return The generic class type of this parameter. - */ - public Type getGenericParameterType() { - return eInfo.getRawGenericParamType(index); - } - - /** - * Returns the generic class type of this parameter. - * - * @return The generic class type of this parameter. - */ - public ClassInfo getGenericParameterTypeInfo() { + public ClassInfo getParameterType() { return eInfo.getParamType(index); } diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java index 9d625a1..9b5ba5b 100644 --- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java +++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java @@ -107,7 +107,7 @@ public final class RemoteMethodArg { return schema; } - static RemoteMethodArg create(MethodParamInfo mpi) { + static RemoteMethodArg create(ParamInfo mpi) { int i = mpi.getIndex(); if (mpi.hasAnnotation(Header.class)) { return new RemoteMethodArg(i, HEADER, HttpPartSchema.create(Header.class, mpi)); diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java index 804edfb..a347ea5 100644 --- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java +++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java @@ -113,7 +113,7 @@ public class RemoteMethodMeta { fullPath = path.indexOf("://") != -1 ? path : (parentPath.isEmpty() ? urlEncodePath(path) : (trimSlashes(parentPath) + '/' + urlEncodePath(path))); - for (MethodParamInfo mpi : mi.getParams()) { + for (ParamInfo mpi : mi.getParams()) { RemoteMethodArg rma = RemoteMethodArg.create(mpi); boolean annotated = false; if (rma != null) { 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 252d3bb..2e5424a 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 @@ -4585,7 +4585,7 @@ public final class RestContext extends BeanContext { rp[i] = RestParamDefaults.STANDARD_RESOLVERS.get(c); } - MethodParamInfo mpi = mi.getParam(i); + ParamInfo mpi = mi.getParam(i); if (mpi.hasAnnotation(Header.class)) { rp[i] = new RestParamDefaults.HeaderObject(mpi, ps); 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 fdbbc49..c91d664 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,7 +115,7 @@ import org.apache.juneau.utils.*; public abstract class RestMethodParam { final RestParamType paramType; - final MethodParamInfo mpi; + final ParamInfo mpi; final String name; final Type type; final Class<?> c; @@ -130,7 +130,7 @@ public abstract class RestMethodParam { * Can be <jk>null</jk> 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, MethodParamInfo mpi, String name, Type type) { + protected RestMethodParam(RestParamType paramType, ParamInfo mpi, String name, Type type) { this.paramType = paramType; this.mpi = mpi; this.name = name; @@ -147,8 +147,8 @@ public abstract class RestMethodParam { * The parameter name. * Can be <jk>null</jk> if parameter doesn't have a name (e.g. the request body). */ - protected RestMethodParam(RestParamType paramType, MethodParamInfo mpi, String name) { - this(paramType, mpi, name, mpi.getGenericParameterType()); + protected RestMethodParam(RestParamType paramType, ParamInfo mpi, String name) { + this(paramType, mpi, name, mpi.getParameterType().innerType()); } /** @@ -157,8 +157,8 @@ public abstract class RestMethodParam { * @param paramType The Swagger parameter type. * @param mpi The method parameter. */ - protected RestMethodParam(RestParamType paramType, MethodParamInfo mpi) { - this(paramType, mpi, null, mpi.getGenericParameterType()); + protected RestMethodParam(RestParamType paramType, ParamInfo mpi) { + this(paramType, mpi, null, mpi.getParameterType().innerType()); } /** @@ -229,7 +229,7 @@ public abstract class RestMethodParam { * * @return The parameter info. */ - public MethodParamInfo getMethodParamInfo() { + public ParamInfo getMethodParamInfo() { return mpi; } 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 efa3002..241a166 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 @@ -18,7 +18,6 @@ import static org.apache.juneau.rest.RestParamType.*; import java.io.*; import java.lang.reflect.*; -import java.lang.reflect.Method; import java.util.*; import javax.servlet.*; @@ -196,13 +195,13 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected PathObject(MethodParamInfo mpi, PropertyStore ps, UrlPathPattern pathPattern) { + protected PathObject(ParamInfo mpi, PropertyStore ps, UrlPathPattern pathPattern) { super(PATH, mpi, getName(mpi, pathPattern)); this.schema = HttpPartSchema.create(Path.class, mpi); this.partParser = createPartParser(schema.getParser(), ps); } - private static String getName(MethodParamInfo mpi, UrlPathPattern pathPattern) { + private static String getName(ParamInfo mpi, UrlPathPattern pathPattern) { for (Path h : mpi.getAnnotations(Path.class)) { if (! h.name().isEmpty()) return h.name(); @@ -212,15 +211,15 @@ class RestParamDefaults { if (pathPattern != null) { int idx = 0; int i = mpi.getIndex(); - Method m = mpi.getMethod(); + MethodInfo mi = mpi.getMethod(); for (int j = 0; j < i; j++) - if (getMethodInfo(m).getParam(i).getAnnotation(Path.class) != null) + if (mi.getParam(i).getAnnotation(Path.class) != null) idx++; String[] vars = pathPattern.getVars(); if (vars.length <= idx) - throw new InternalServerError("Number of attribute parameters in method ''{0}'' exceeds the number of URL pattern variables.", m); + throw new InternalServerError("Number of attribute parameters in method ''{0}'' exceeds the number of URL pattern variables.", mi.getShortName()); // Check for {#} variables. String idxs = String.valueOf(idx); @@ -242,7 +241,7 @@ class RestParamDefaults { static final class BodyObject extends RestMethodParam { private final HttpPartSchema schema; - protected BodyObject(MethodParamInfo mpi, PropertyStore ps) { + protected BodyObject(ParamInfo mpi, PropertyStore ps) { super(BODY, mpi); this.schema = HttpPartSchema.create(Body.class, mpi); } @@ -257,13 +256,13 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected HeaderObject(MethodParamInfo mpi, PropertyStore ps) { + protected HeaderObject(ParamInfo mpi, PropertyStore ps) { super(HEADER, mpi, getName(mpi)); this.schema = HttpPartSchema.create(Header.class, mpi); this.partParser = createPartParser(schema.getParser(), ps); } - private static String getName(MethodParamInfo mpi) { + private static String getName(ParamInfo mpi) { for (Header h : mpi.getAnnotations(Header.class)) { if (! h.name().isEmpty()) return h.name(); @@ -282,7 +281,7 @@ class RestParamDefaults { static final class RequestObject extends RestMethodParam { private final RequestBeanMeta meta; - protected RequestObject(MethodParamInfo mpi, PropertyStore ps) { + protected RequestObject(ParamInfo mpi, PropertyStore ps) { super(RESPONSE_BODY, mpi); this.meta = RequestBeanMeta.create(mpi, ps); } @@ -296,7 +295,7 @@ class RestParamDefaults { static final class ResponseHeaderObject extends RestMethodParam { final ResponsePartMeta meta; - protected ResponseHeaderObject(MethodParamInfo mpi, PropertyStore ps) { + protected ResponseHeaderObject(ParamInfo mpi, PropertyStore ps) { super(RESPONSE_HEADER, mpi, getName(mpi)); HttpPartSchema schema = HttpPartSchema.create(ResponseHeader.class, mpi); this.meta = new ResponsePartMeta(HttpPartType.HEADER, schema, createPartSerializer(schema.getSerializer(), ps)); @@ -305,7 +304,7 @@ class RestParamDefaults { throw new InternalServerError("Invalid type {0} specified with @ResponseHeader annotation. It must be Value.", type); } - private static String getName(MethodParamInfo mpi) { + private static String getName(ParamInfo mpi) { for (ResponseHeader h : mpi.getAnnotations(ResponseHeader.class)) { if (! h.name().isEmpty()) return h.name(); @@ -339,7 +338,7 @@ class RestParamDefaults { static final class ResponseObject extends RestMethodParam { final ResponseBeanMeta meta; - protected ResponseObject(MethodParamInfo mpi, PropertyStore ps) { + protected ResponseObject(ParamInfo mpi, PropertyStore ps) { super(RESPONSE, mpi); this.meta = ResponseBeanMeta.create(mpi, ps); if (getTypeClass() != Value.class) @@ -389,7 +388,7 @@ class RestParamDefaults { static final class MethodObject extends RestMethodParam { protected MethodObject(MethodInfo m, ClassInfo t) throws ServletException { - super(OTHER, (MethodParamInfo)null); + super(OTHER, (ParamInfo)null); if (! t.is(String.class)) throw new RestServletException("Use of @Method annotation on parameter that is not a String on method ''{0}''", m.inner()); } @@ -405,7 +404,7 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected FormDataObject(MethodParamInfo mpi, PropertyStore ps) { + protected FormDataObject(ParamInfo mpi, PropertyStore ps) { super(FORM_DATA, mpi, getName(mpi)); this.schema = HttpPartSchema.create(FormData.class, mpi); this.partParser = createPartParser(schema.getParser(), ps); @@ -415,7 +414,7 @@ class RestParamDefaults { throw new InternalServerError("Use of multipart flag on @FormData parameter that's not an array or Collection on method ''{0}''", mpi.getMethod()); } - private static String getName(MethodParamInfo mpi) { + private static String getName(ParamInfo mpi) { for (FormData h : mpi.getAnnotations(FormData.class)) { if (! h.name().isEmpty()) return h.name(); @@ -438,7 +437,7 @@ class RestParamDefaults { private final HttpPartParser partParser; private final HttpPartSchema schema; - protected QueryObject(MethodParamInfo mpi, PropertyStore ps) { + protected QueryObject(ParamInfo mpi, PropertyStore ps) { super(QUERY, mpi, getName(mpi)); this.schema = HttpPartSchema.create(Query.class, mpi); this.partParser = createPartParser(schema.getParser(), ps); @@ -448,7 +447,7 @@ class RestParamDefaults { throw new InternalServerError("Use of multipart flag on @Query parameter that's not an array or Collection on method ''{0}''", mpi.getMethod()); } - private static String getName(MethodParamInfo mpi) { + private static String getName(ParamInfo mpi) { for (Query h : mpi.getAnnotations(Query.class)) { if (! h.name().isEmpty()) return h.name(); @@ -468,13 +467,13 @@ class RestParamDefaults { static final class HasFormDataObject extends RestMethodParam { - protected HasFormDataObject(MethodParamInfo mpi) throws ServletException { + protected HasFormDataObject(ParamInfo mpi) throws ServletException { super(FORM_DATA, mpi, getName(mpi)); if (getType() != Boolean.class && getType() != boolean.class) throw new RestServletException("Use of @HasForm annotation on parameter that is not a boolean on method ''{0}''", mpi.getMethod()); } - private static String getName(MethodParamInfo mpi) { + private static String getName(ParamInfo mpi) { for (HasFormData h : mpi.getAnnotations(HasFormData.class)) { if (! h.name().isEmpty()) return h.name(); @@ -493,13 +492,13 @@ class RestParamDefaults { static final class HasQueryObject extends RestMethodParam { - protected HasQueryObject(MethodParamInfo mpi) throws ServletException { + protected HasQueryObject(ParamInfo mpi) throws ServletException { super(QUERY, mpi, getName(mpi)); if (getType() != Boolean.class && getType() != boolean.class) throw new RestServletException("Use of @HasQuery annotation on parameter that is not a boolean on method ''{0}''", mpi.getMethod()); } - private static String getName(MethodParamInfo mpi) { + private static String getName(ParamInfo mpi) { for (HasQuery h : mpi.getAnnotations(HasQuery.class)) { if (! h.name().isEmpty()) return h.name(); diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java index 375285a..8b76cb6 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java @@ -328,7 +328,7 @@ final class SwaggerGenerator { for (RestMethodParam mp : context.getRestMethodParams(m)) { RestParamType in = mp.getParamType(); - MethodParamInfo mpi = mp.getMethodParamInfo(); + ParamInfo mpi = mp.getMethodParamInfo(); if (in.isAny(BODY, QUERY, FORM_DATA, HEADER, PATH)) { @@ -445,7 +445,7 @@ final class SwaggerGenerator { for (RestMethodParam mp : context.getRestMethodParams(m)) { RestParamType in = mp.getParamType(); - MethodParamInfo mpi = mp.getMethodParamInfo(); + ParamInfo mpi = mp.getMethodParamInfo(); if (in == RESPONSE_HEADER) { List<ResponseHeader> la = mpi.getAnnotations(ResponseHeader.class, true);