io.sphere.sdk.http.HttpResponse.hasSuccessResponseCode()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中io.sphere.sdk.http.HttpResponse.hasSuccessResponseCode()方法的一些代码示例,展示了HttpResponse.hasSuccessResponseCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.hasSuccessResponseCode()方法的具体详情如下:
包路径:io.sphere.sdk.http.HttpResponse
类名称:HttpResponse
方法名:hasSuccessResponseCode

HttpResponse.hasSuccessResponseCode介绍

暂无

代码示例

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

@Override
  public boolean canDeserialize(final HttpResponse httpResponse) {
    return httpResponse.hasSuccessResponseCode() || httpResponse.getStatusCode() == NOT_FOUND_404;
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
public boolean canDeserialize(final HttpResponse httpResponse) {
  return httpResponse.hasSuccessResponseCode() || httpResponse.getStatusCode() == NOT_FOUND_404;
}

代码示例来源:origin: io.sphere.sdk.jvm/common

/**
   Checks if the response can be handled by {@link #resultMapper()}.

   Use case 1: A http response returns 404 and the this {@link SphereRequest}
   can handle this error by returning an empty optional, an empty list or throwing a domain specific exception.

   @param response the http response which shall be transformed
   @return true if the http response can be consumed, false otherwise
   */
  default boolean canHandleResponse(final HttpResponse response) {
    return response.hasSuccessResponseCode() && response.getResponseBody().isPresent();
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/models

@Override
  public boolean canHandleResponse(final HttpResponse response) {
    return response.hasSuccessResponseCode() || response.getStatusCode() == NOT_FOUND_404;
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

/**
   Checks if the response can be handled by {@link #deserialize(HttpResponse)}.

   Use case 1: A http response returns 404 and the this {@link SphereRequest}
   can handle this error by returning an empty optional, an empty list or throwing a domain specific exception.

   @param httpResponse the http response which shall be transformed
   @return true if the http response can be consumed, false otherwise
   */
  default boolean canDeserialize(final HttpResponse httpResponse) {
    return httpResponse.hasSuccessResponseCode() && httpResponse.getResponseBody() != null;
  }
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

@Override
  public boolean canDeserialize(final HttpResponse httpResponse) {
    return httpResponse.hasSuccessResponseCode() || httpResponse.getStatusCode() == NOT_FOUND_404;
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/common

@Override
  public boolean canHandleResponse(final HttpResponse response) {
    return response.hasSuccessResponseCode() || response.getStatusCode() == NOT_FOUND_404;
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
  public boolean canDeserialize(final HttpResponse httpResponse) {
    return httpResponse.hasSuccessResponseCode() || httpResponse.getStatusCode() == NOT_FOUND_404;
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/common

@Override
public boolean canHandleResponse(final HttpResponse response) {
  return response.hasSuccessResponseCode() || response.getStatusCode() == NOT_FOUND_404;
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

protected CustomObject<T> deserializeCustomObject(final HttpResponse httpResponse) {
  if(!httpResponse.hasSuccessResponseCode()){
    return null;
  }
  return Optional.ofNullable(httpResponse)
      .filter(response -> response.getResponseBody() != null && response.getResponseBody().length > 0)
      .map(response -> response.getResponseBody())
      .map(responseBody -> SphereJsonUtils.<CustomObject<T>>readObject(httpResponse.getResponseBody(), customObjectJavaType))
      .orElse(null);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

protected CustomObject<T> deserializeCustomObject(final HttpResponse httpResponse) {

    if(!httpResponse.hasSuccessResponseCode()){
      return null;
    }

    return Optional.ofNullable(httpResponse)
        .filter(response -> response.getResponseBody() != null && response.getResponseBody().length > 0)
        .map(response -> response.getResponseBody())
        .map(responseBody -> SphereJsonUtils.<CustomObject<T>>readObject(httpResponse.getResponseBody(), customObjectJavaType))
        .orElse(null);
  }
}

相关文章