@Test public void unwrapConstraintViolationException() { ConstraintViolationException validationException = new ConstraintViolationException(Collections.emptySet()); Throwable exception = new Exception(validationException); Optional<ConstraintViolationException> result = JaxbUtil.unwrapConstraintViolationException(exception); assertThat(result).isPresent(); assertThat(result.get()).isSameAs(validationException); }
protected static Optional<ConstraintViolationException> unwrapConstraintViolationException(Throwable ex) { return Optional.of(ex) .map(Throwable::getCause) .filter(Objects::nonNull) .filter(ConstraintViolationException.class::isInstance) .map(ConstraintViolationException.class::cast); }
JaxbUtil { protected static Optional<ConstraintViolationException> unwrapConstraintViolationException(Throwable ex) { return Optional.of(ex) .map(Throwable::getCause) .filter(Objects::nonNull) .filter(ConstraintViolationException.class::isInstance) .map(ConstraintViolationException.class::cast); } }
JaxbUtil { protected static Optional<ConstraintViolationException> unwrapConstraintViolationException(Throwable ex) { return Optional.of(ex) .map(Throwable::getCause) .filter(Objects::nonNull) .filter(ConstraintViolationException.class::isInstance) .map(ConstraintViolationException.class::cast); } private  JaxbUtil(); }
JaxbUtil { protected static Optional<ConstraintViolationException> unwrapConstraintViolationException(Throwable ex) { return Optional.of(ex) .map(Throwable::getCause) .filter(Objects::nonNull) .filter(ConstraintViolationException.class::isInstance) .map(ConstraintViolationException.class::cast); } private  JaxbUtil(); static T unmarshal(InputStream inputStream, Class<T> type); static void marshal(Object object, OutputStream outputStream); static void marshalWithNoValidation(Object object, OutputStream outputStream); static String marshalToString(Object object); static String marshalToStringNoValidation(Object object); static void marshalMasked(Config object, OutputStream outputStream); }
JaxbUtil { protected static Optional<ConstraintViolationException> unwrapConstraintViolationException(Throwable ex) { return Optional.of(ex) .map(Throwable::getCause) .filter(Objects::nonNull) .filter(ConstraintViolationException.class::isInstance) .map(ConstraintViolationException.class::cast); } private  JaxbUtil(); static T unmarshal(InputStream inputStream, Class<T> type); static void marshal(Object object, OutputStream outputStream); static void marshalWithNoValidation(Object object, OutputStream outputStream); static String marshalToString(Object object); static String marshalToStringNoValidation(Object object); static void marshalMasked(Config object, OutputStream outputStream); static final Class[] JAXB_CLASSES; }