private Optional getMatchingAnnotation()

in src/main/java/org/apache/fineract/cn/api/util/AnnotatedErrorDecoder.java [93:114]


  private Optional<ThrowsException> getMatchingAnnotation(
      final Response response,
      final Method method) {

    final ThrowsExceptions throwsExceptionsAnnotation =
        method.getAnnotation(ThrowsExceptions.class);
    if (throwsExceptionsAnnotation == null) {
      final ThrowsException throwsExceptionAnnotation =
          method.getAnnotation(ThrowsException.class);
      if ((throwsExceptionAnnotation != null) &&
          statusMatches(response, throwsExceptionAnnotation)) {
        return Optional.of(throwsExceptionAnnotation);
      }
    } else {
      return Arrays.stream(throwsExceptionsAnnotation.value())
          .filter(throwsExceptionAnnotation -> statusMatches(response,
              throwsExceptionAnnotation))
          .findAny();
    }

    return Optional.empty();
  }