use of java.lang.reflect.Parameter in project completable-reactor by ru-fix.
the class LambdaReflector method signature.
static String signature(Method method) {
StringBuilder signature = new StringBuilder();
Parameter[] parameters = method.getParameters();
signature.append("(");
for (Parameter parameter : parameters) {
signature.append(signatureMapType(parameter.getType()));
}
signature.append(")");
signature.append(signatureMapType(method.getReturnType()));
return signature.toString();
}
use of java.lang.reflect.Parameter in project tutorials by eugenp.
the class SpringExtension method resolveParameter.
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
Parameter parameter = parameterContext.getParameter();
Class<?> testClass = extensionContext.getTestClass().get();
ApplicationContext applicationContext = getApplicationContext(extensionContext);
return ParameterAutowireUtils.resolveDependency(parameter, testClass, applicationContext);
}
use of java.lang.reflect.Parameter in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_CodeStructureTest method shouldGenerateClassContainingMethodWithThreePathParamsAndOneBodyParam.
@Test
public void shouldGenerateClassContainingMethodWithThreePathParamsAndOneBodyParam() throws Exception {
generator.run(restRamlWithCommandApiDefaults().with(defaultPostResource().withRelativeUri("/some/path/{paramA}/{paramB}/{paramC}").withPathParam("paramA").withPathParam("paramB").withPathParam("paramC")).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> clazz = compiler.compiledClassOf(BASE_PACKAGE, "resource", "DefaultCommandApiSomePathParamAParamBParamCResource");
assertThat(clazz.isInterface(), is(false));
final List<Method> methods = methodsOf(clazz);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getParameterCount(), is(4));
final Parameter pathParam1 = method.getParameters()[0];
assertThat(pathParam1.getType(), equalTo(String.class));
assertThat(pathParam1.getAnnotations(), emptyArray());
final Parameter pathParam2 = method.getParameters()[1];
assertThat(pathParam2.getType(), equalTo(String.class));
assertThat(pathParam2.getAnnotations(), emptyArray());
final Parameter pathParam3 = method.getParameters()[2];
assertThat(pathParam3.getType(), equalTo(String.class));
assertThat(pathParam3.getAnnotations(), emptyArray());
final Parameter bodyParam = method.getParameters()[3];
assertThat(bodyParam.getType(), equalTo(JsonObject.class));
assertThat(bodyParam.getAnnotations(), emptyArray());
}
use of java.lang.reflect.Parameter in project microservice_framework by CJSCommonPlatform.
the class RestAdapterGenerator_MultipartCodeStructureTest method shouldGenerateInterfaceThatContainsMethodWithTwoPathParamsAndMultipartParameter.
@Test
public void shouldGenerateInterfaceThatContainsMethodWithTwoPathParamsAndMultipartParameter() throws Exception {
generator.run(restRamlWithDefaults().with(resource("/some/path").with(httpAction().withHttpActionType(POST).withMediaTypeWithoutSchema(multipartWithFileFormParameter("photoId")).with(mapping().withName("upload").withRequestType(MULTIPART_FORM_DATA))).withRelativeUri("/some/path/{paramA}/abc/{paramB}").withPathParam("paramA").withPathParam("paramB")).build(), configurationWithBasePackage(BASE_PACKAGE, outputFolder, new CommonGeneratorProperties()));
final Class<?> interfaceClass = compiler.compiledInterfaceOf(RESOURCE_PACKAGE);
final List<Method> methods = methodsOf(interfaceClass);
assertThat(methods, hasSize(1));
final Method method = methods.get(0);
assertThat(method.getParameterCount(), is(3));
final Parameter methodParam1 = method.getParameters()[0];
assertThat(methodParam1.getType(), equalTo(String.class));
assertThat(methodParam1.getAnnotations(), arrayWithSize(1));
assertThat(methodParam1.getAnnotations()[0].annotationType(), equalTo(PathParam.class));
assertThat(methodParam1.getAnnotation(PathParam.class).value(), is("paramA"));
final Parameter methodParam2 = method.getParameters()[1];
assertThat(methodParam2.getType(), equalTo(String.class));
assertThat(methodParam2.getAnnotations(), arrayWithSize(1));
assertThat(methodParam2.getAnnotations()[0].annotationType(), equalTo(PathParam.class));
assertThat(methodParam2.getAnnotation(PathParam.class).value(), is("paramB"));
final Parameter methodParam3 = method.getParameters()[2];
assertThat(methodParam3.getType(), equalTo(MultipartFormDataInput.class));
assertThat(methodParam3.getAnnotation(MultipartForm.class), not(nullValue()));
}
use of java.lang.reflect.Parameter in project kalang by kasonyang.
the class JvmClassNode method getDeclaredMethodNodes.
@Override
public MethodNode[] getDeclaredMethodNodes() {
if (!this.methodsInitialized) {
this.methodsInitialized = true;
List<Executable> methods = new LinkedList();
methods.addAll(Arrays.asList(clazz.getDeclaredMethods()));
methods.addAll(Arrays.asList(clazz.getDeclaredConstructors()));
for (Executable m : methods) {
NullableKind nullable = getNullable(m.getAnnotations());
Type mType;
String mName;
int mModifier;
if (m instanceof Method) {
mType = getType(((Method) m).getGenericReturnType(), getGenericTypeMap(), ((Method) m).getReturnType(), nullable);
mName = m.getName();
mModifier = m.getModifiers();
} else if (m instanceof Constructor) {
mName = "<init>";
// getType(clz);
mType = Types.VOID_TYPE;
// | Modifier.STATIC;
mModifier = m.getModifiers();
} else {
throw Exceptions.unexceptedValue(m);
}
MethodNode methodNode = createMethodNode(mType, mName, mModifier);
for (Parameter p : m.getParameters()) {
NullableKind pnullable = getNullable(p.getAnnotations());
methodNode.createParameter(getType(p.getParameterizedType(), getGenericTypeMap(), p.getType(), pnullable), p.getName());
}
for (Class e : m.getExceptionTypes()) {
methodNode.addExceptionType(getType(e, getGenericTypeMap(), e, NullableKind.NONNULL));
}
}
}
return super.getDeclaredMethodNodes();
}
Aggregations