@Override public String contentAsText() { if (contentAsText == null) { contentAsText = ContentHolder.super.contentAsText(); } return contentAsText; }
@Override public String contentAsText() { if (contentAsText == null) { contentAsText = ContentHolder.super.contentAsText(); } return contentAsText; }
@Override public String contentAsText() { if (contentAsText == null) { contentAsText = ContentHolder.super.contentAsText(); } return contentAsText; }
@Override public String contentAsText() { if (contentAsText == null) { contentAsText = ContentHolder.super.contentAsText(); } return contentAsText; }
/** * Returns the JSON representation of the specified content. * * @return the {@link JsonNode} parsed from the content * * @throws IllegalStateException if the content is {@code null} * @throws JsonParseException if failed to parse the content as JSON */ default JsonNode contentAsJson() throws JsonParseException { final T content = content(); if (content instanceof JsonNode) { return (JsonNode) content; } return Jackson.readTree(contentAsText()); }
/** * Returns the JSON representation of the specified content. * * @return the {@link JsonNode} parsed from the content * * @throws IllegalStateException if the content is {@code null} * @throws JsonParseException if failed to parse the content as JSON */ default JsonNode contentAsJson() throws JsonParseException { final T content = content(); if (content instanceof JsonNode) { return (JsonNode) content; } return Jackson.readTree(contentAsText()); }
/** * Returns the value converted from the JSON representation of the specified content. * * @return the value converted from the content * * @throws IllegalStateException if the content is {@code null} * @throws JsonParseException if failed to parse the content as JSON * @throws JsonMappingException if failed to convert the parsed JSON into {@code valueType} */ default <U> U contentAsJson(Class<U> valueType) throws JsonParseException, JsonMappingException { final T content = content(); if (content instanceof TreeNode) { return Jackson.treeToValue((TreeNode) content, valueType); } return Jackson.readValue(contentAsText(), valueType); } }
/** * Returns the value converted from the JSON representation of the specified content. * * @return the value converted from the content * * @throws IllegalStateException if the content is {@code null} * @throws JsonParseException if failed to parse the content as JSON * @throws JsonMappingException if failed to convert the parsed JSON into {@code valueType} */ default <U> U contentAsJson(Class<U> valueType) throws JsonParseException, JsonMappingException { final T content = content(); if (content instanceof TreeNode) { return Jackson.treeToValue((TreeNode) content, valueType); } return Jackson.readValue(contentAsText(), valueType); } }