private Annotation getAnnotationFromConstraintViolationException()

in digital-document-service/src/main/java/com/epam/digital/data/platform/dgtldcmnt/exception/RestExceptionHandler.java [148:158]


  private Annotation getAnnotationFromConstraintViolationException(
      ConstraintViolationException exception) {
    var constraintViolations = exception.getConstraintViolations();
    if (constraintViolations != null && !constraintViolations.isEmpty()) {
      var next = constraintViolations.iterator().next();
      if (next != null && next.getConstraintDescriptor() != null) {
        return next.getConstraintDescriptor().getAnnotation();
      }
    }
    return null;
  }