throw new IllegalStateException();
}
}
//
MethodIntrospector introspector = new MethodIntrospector(HierarchyScope.ALL);
// Create
for (MethodInfo method : introspector.resolveMethods(javaClass, Create.class)) {
if (!method.isStatic()) {
List<TypeInfo> parameterTypes = method.getParameterTypes();
if (parameterTypes.size() < 2) {
if (parameterTypes.size() == 1) {
TypeInfo argTI = parameterTypes.get(0);
if (argTI instanceof ClassTypeInfo) {
ClassTypeInfo argCTI = (ClassTypeInfo)argTI;
if (!argCTI.getName().equals(String.class.getName())) {
throw new IllegalStateException();
}
} else {
throw new IllegalStateException();
}
}
ClassTypeInfo cti = (ClassTypeInfo)javaClass.resolve(method.getReturnType());
methodMappings.add(new CreateMapping(method, cti));
} else {
throw new IllegalStateException();
}
}
}
// Destroy
for (MethodInfo method : introspector.resolveMethods(javaClass, Destroy.class)) {
if (!method.isStatic()) {
List<TypeInfo> parameterTypes = method.getParameterTypes();
if (parameterTypes.size() != 0) {
throw new IllegalStateException();
}
if (!(method.getReturnType() instanceof VoidTypeInfo)) {
throw new IllegalStateException();
}
methodMappings.add(new DestroyMapping(method));
}
}
// Find by id
for (MethodInfo method : introspector.resolveMethods(javaClass, FindById.class)) {
if (!method.isStatic()) {
List<TypeInfo> parameterTypes = method.getParameterTypes();
if (parameterTypes.size() == 1) {
TypeInfo argTI = parameterTypes.get(0);
if (argTI instanceof ClassTypeInfo) {