示例#1
0
  /**
   * Gets the error documentation for the resource method annotation.
   *
   * @param resourceMethod Endpoint method to document.
   * @return a list of ResponseErrors in the parameter
   */
  List<ResponseError> getResponseErrors(ResourceMethod resourceMethod) {
    if (null == resourceMethod) return Collections.emptyList();

    final Collection<ResponseError> errors =
        Collections2.transform(
            Arrays.asList(resourceMethod.errors()),
            new Function<MethodError, ResponseError>() {
              @Override
              public ResponseError apply(MethodError from) {
                return new ResponseError(from.status().getStatusCode(), from.cause());
              }
            });

    return ImmutableList.copyOf(errors);
  }