public abstract ReturnTypeEnum getReturnType();
@Override
public Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException {
IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theResponseStatusCode);
switch (getReturnType()) {
case BUNDLE: {
Bundle bundle;
if (myResourceType != null) {
bundle = parser.parseBundle(myResourceType, theResponseReader);
} else {
bundle = parser.parseBundle(theResponseReader);
}
switch (getMethodReturnType()) {
case BUNDLE:
return bundle;
case LIST_OF_RESOURCES:
return bundle.toListOfResources();
case RESOURCE:
List<IResource> list = bundle.toListOfResources();
if (list.size() == 0) {
return null;
} else if (list.size() == 1) {
return list.get(0);
} else {
throw new InvalidResponseException(theResponseStatusCode, "FHIR server call returned a bundle with multiple resources, but this method is only able to returns one.");
}
case BUNDLE_PROVIDER:
throw new IllegalStateException("Return type of " + IBundleProvider.class.getSimpleName() + " is not supported in clients");
}
break;
}
case RESOURCE: {
IResource resource;
if (myResourceType != null) {
resource = parser.parseResource(myResourceType, theResponseReader);
} else {
resource = parser.parseResource(theResponseReader);
}
MethodUtil.parseClientRequestResourceHeaders(theHeaders, resource);
switch (getMethodReturnType()) {