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 core by weld.
the class ObserverMethodConfiguratorImpl method read.
@Override
public ObserverMethodConfigurator<T> read(Method method) {
checkArgumentNotNull(method);
Set<Parameter> eventParameters = Configurators.getAnnotatedParameters(method, Observes.class, ObservesAsync.class);
checkEventParams(eventParameters, method);
Parameter eventParameter = eventParameters.iterator().next();
Observes observesAnnotation = eventParameter.getAnnotation(Observes.class);
if (observesAnnotation != null) {
reception(observesAnnotation.notifyObserver());
transactionPhase(observesAnnotation.during());
} else {
reception(eventParameter.getAnnotation(ObservesAsync.class).notifyObserver());
}
Priority priority = method.getAnnotation(Priority.class);
if (priority != null) {
priority(priority.value());
}
beanClass(eventParameter.getDeclaringExecutable().getDeclaringClass());
observedType(eventParameter.getType());
qualifiers(Configurators.getQualifiers(eventParameter));
return this;
}
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();
}
use of java.lang.reflect.Parameter in project vertx-zero by silentbalanceyh.
the class Verifier method verify.
public static void verify(final Event event) {
final Method method = event.getAction();
Fn.flingUp(null == method, LOGGER, EventActionNoneException.class, Verifier.class, event);
/**
* Specification *
*/
verify(method, BodyParam.class);
verify(method, StreamParam.class);
/**
* Field Specification *
*/
for (final Parameter parameter : method.getParameters()) {
verify(parameter);
}
}
Aggregations