private Class getAnnotation()

in src/main/java/com/epam/digital/data/platform/excerpt/api/audit/ControllerAuditAspect.java [97:112]


  private Class<? extends Annotation> getAnnotation(ProceedingJoinPoint joinPoint) {
    var annotations = Arrays.stream(((MethodSignature) joinPoint.getSignature())
            .getMethod()
            .getAnnotations())
        .map(Annotation::annotationType)
        .collect(Collectors.toCollection(ArrayList::new));

    annotations.retainAll(httpAnnotations);
    if (annotations.size() != 1) {
      throw new AuditException(
          String.format(
              "The request handler must have exactly one mapping annotation, but has %d: %s", 
              annotations.size(), annotations));
    }
    return annotations.get(0);
  }