JavaClass newType = helper.getJavaClass(Object.class);
ArrayList<JavaMethod> marshalMethods = new ArrayList<JavaMethod>();
// Look for marshal method
for (Iterator<JavaMethod> methodIt = adapterClass.getMethods().iterator(); methodIt.hasNext(); ) {
JavaMethod method = methodIt.next();
if (method.getName().equals(MARSHAL_METHOD_NAME)) {
JavaClass returnType = method.getReturnType();
// Try and find a marshal method where Object is not the return type,
// to avoid processing an inherited default marshal method
if (!returnType.getQualifiedName().equals(newType.getQualifiedName())) {
if (!returnType.isInterface()) {
newType = (JavaClass) method.getReturnType();
setTypeFromAdapterClass(newType, method.getParameterTypes()[0]);
return;
}
}
// Found a marshal method with an Object return type; add
// it to the list in case we need to process it later
marshalMethods.add(method);
}
}
// If there are no marshal methods to process just set type
// and original type, then return
if (marshalMethods.size() == 0) {
setTypeFromAdapterClass(newType, null);
return;
}
// At this point we didn't find a marshal method with a non-Object return type
for (JavaMethod method : marshalMethods) {
JavaClass paramType = method.getParameterTypes()[0];
// look for non-Object parameter type
if (!paramType.getQualifiedName().equals(newType.getQualifiedName())) {
setTypeFromAdapterClass(newType, paramType);
return;
}