private static void completeOperationThrows(
      CollectInfo collectInfo,
      Operation operation,
      MethodAnnotationInfo mai,
      List<? extends IntrospectionHelper> introspectionHelper) {
    Class<?>[] thrownClasses = mai.getJavaMethod().getExceptionTypes();
    if (thrownClasses != null) {
      for (Class<?> thrownClass : thrownClasses) {
        ThrowableAnnotationInfo throwableAnnotationInfo =
            AnnotationUtils.getInstance().getThrowableAnnotationInfo(thrownClass);
        if (throwableAnnotationInfo != null) {
          int statusCode = throwableAnnotationInfo.getStatus().getCode();
          Response response = new Response();
          response.setCode(statusCode);
          response.setName(Status.valueOf(statusCode).getReasonPhrase());
          response.setMessage("Status " + statusCode);

          Class<?> outputPayloadType =
              throwableAnnotationInfo.isSerializable() ? thrownClass : StatusInfo.class;
          TypeInfo outputTypeInfo = null;
          try {
            outputTypeInfo = Types.getTypeInfo(outputPayloadType, null);
          } catch (UnsupportedTypeException e) {
            LOGGER.warning(
                "Could not add output payload for exception "
                    + thrownClass
                    + " throws by method "
                    + mai.getJavaMethod()
                    + ". "
                    + e.getMessage());
            continue;
          }

          RepresentationCollector.addRepresentation(
              collectInfo, outputTypeInfo, introspectionHelper);

          PayLoad outputPayLoad = new PayLoad();
          outputPayLoad.setType(outputTypeInfo.getRepresentationName());
          response.setOutputPayLoad(outputPayLoad);
          operation.getResponses().add(response);
        }
      }
    }
  }
  private static void completeOperationOutput(
      CollectInfo collectInfo,
      Operation operation,
      MethodAnnotationInfo mai,
      List<? extends IntrospectionHelper> introspectionHelper) {
    Response response = new Response();

    if (mai.getJavaMethod().getReturnType() != Void.TYPE) {
      TypeInfo outputTypeInfo;
      try {
        outputTypeInfo =
            Types.getTypeInfo(
                mai.getJavaMethod().getReturnType(), mai.getJavaMethod().getGenericReturnType());
      } catch (UnsupportedTypeException e) {
        LOGGER.warning(
            "Could not add output representation of method "
                + mai.getJavaMethod()
                + ". "
                + e.getMessage());
        return;
      }
      // Output representation
      RepresentationCollector.addRepresentation(collectInfo, outputTypeInfo, introspectionHelper);

      PayLoad outputEntity = new PayLoad();
      outputEntity.setType(outputTypeInfo.getRepresentationName());
      outputEntity.setArray(outputTypeInfo.isList());

      response.setOutputPayLoad(outputEntity);

      response.setCode(Status.SUCCESS_OK.getCode());
      response.setName(Status.SUCCESS_OK.getReasonPhrase());
      response.setDescription("");
      response.setMessage(Status.SUCCESS_OK.getDescription());
    } else {
      response.setCode(Status.SUCCESS_NO_CONTENT.getCode());
      response.setName(Status.SUCCESS_NO_CONTENT.getReasonPhrase());
      response.setDescription("");
      response.setMessage(Status.SUCCESS_NO_CONTENT.getDescription());
    }

    operation.getResponses().add(response);
  }