@Nullable @Override public JsonNode deserialize(final HttpResponse httpResponse) { return Optional.ofNullable(httpResponse.getResponseBody()) .map(body -> SphereJsonUtils.readObject(body, TypeReferences.jsonNodeTypeReference())) .orElse(null); }
public static JsonNodeSphereRequest of( final HttpMethod httpMethod, final String path, @Nullable final JsonNode body) { final HttpRequestIntent httpRequestIntent = Optional.ofNullable(body) .map(b -> HttpRequestIntent.of(httpMethod, path, SphereJsonUtils.toJsonString(b))) .orElseGet(() -> HttpRequestIntent.of(httpMethod, path)); return of(httpRequestIntent); }