public <T> T getMandatoryBody(Class<T> type) throws InvalidPayloadException {
Exchange e = getExchange();
if (e != null) {
TypeConverter converter = e.getContext().getTypeConverter();
try {
return converter.mandatoryConvertTo(type, e, getBody());
} catch (Exception cause) {
throw new InvalidPayloadException(e, type, this, cause);
}
}
throw new InvalidPayloadException(e, type, this);