int count = 0;
for(Map.Entry<UriRef, Object> entry : parts.entrySet()) {
if (count == index) {
result = entry.getValue();
if (!result.getClass().isAssignableFrom(clazz)) {
throw new NoSuchPartException("The body part 0 is of type "+result.getClass().getName()+" which cannot be converted to "+clazz.getName());
}
return (T) result;
}
count++;
}
} finally {
readLock.unlock();
}
throw new NoSuchPartException(index);
}