class ValidationExceptionMessageExtractor {

    public void extract(MessageContext context, ValidationException e) {
        if (e.hasChildExceptions()) {
            List<ValidationException> children = e.getChildExceptions();
            for (ValidationException child : children) {
                if (child instanceof BadNumericResponseException) {
                    extractBadNumericResponseException(context, (BadNumericResponseException) child);
                } else if (child instanceof MandatoryAnswerNotFoundException) {
                    extractMandatoryAnswerNotFoundException(context, (MandatoryAnswerNotFoundException) child);
                } else {
                    extractDefault(context, child);
                }
            }
        }
    }

}