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);
  }
  private static void completeOperationInput(
      CollectInfo collectInfo,
      Operation operation,
      MethodAnnotationInfo mai,
      ServerResource sr,
      List<? extends IntrospectionHelper> introspectionHelper,
      MetadataService metadataService) {
    Class<?>[] inputClasses = mai.getJavaMethod().getParameterTypes();
    if (inputClasses != null && inputClasses.length > 0) {

      // Input representation
      // Handles only the first method parameter
      TypeInfo inputTypeInfo;
      try {
        inputTypeInfo =
            Types.getTypeInfo(inputClasses[0], mai.getJavaMethod().getGenericParameterTypes()[0]);
      } catch (UnsupportedTypeException e) {
        LOGGER.warning(
            "Could not add input representation of method"
                + mai.getJavaMethod()
                + ". "
                + e.getMessage());
        return;
      }

      RepresentationCollector.addRepresentation(collectInfo, inputTypeInfo, introspectionHelper);

      PayLoad inputEntity = new PayLoad();
      inputEntity.setType(inputTypeInfo.getRepresentationName());
      inputEntity.setArray(inputTypeInfo.isList());
      operation.setInputPayLoad(inputEntity);

      // Consumes
      if (metadataService != null) {

        try {
          List<Variant> requestVariants =
              mai.getRequestVariants(metadataService, sr.getConverterService());

          if (requestVariants == null || requestVariants.isEmpty()) {
            LOGGER.warning(
                "Could not add consumes of method "
                    + mai.getJavaMethod()
                    + ". There is no requested variant");
            return;
          }

          // une representation per variant ?
          for (Variant variant : requestVariants) {

            if (variant.getMediaType() == null) {
              LOGGER.warning("Variant has no media type: " + variant);
              continue;
            }

            operation.getConsumes().add(variant.getMediaType().getName());
          }
        } catch (IOException e) {
          throw new ResourceException(e);
        }
      }
    }
  }