/** * Returns the content of this {@link Entry}. * * @throws IllegalStateException if this {@link Entry} is a directory */ public T content() { ensureContent(); return content; }
/** * Returns the prettified textual representation of {@link #content()}. Only a {@link TreeNode} is * prettified currently. * * @throws IllegalStateException if this {@link Entry} is a directory */ public String contentAsPrettyText() { ensureContent(); if (contentAsPrettyText == null) { if (content instanceof TreeNode) { try { contentAsPrettyText = Jackson.writeValueAsPrettyString(content); } catch (JsonProcessingException e) { // Should never happen because it's a JSON tree already. throw new Error(e); } } else { contentAsPrettyText = content.toString(); } } return contentAsPrettyText; }
/** * Returns the textual representation of {@link #content()}. * * @throws IllegalStateException if this {@link Entry} is a directory */ public String contentAsText() { ensureContent(); if (contentAsText == null) { if (content instanceof JsonNode) { try { contentAsText = Jackson.writeValueAsString(content); } catch (JsonProcessingException e) { // Should never happen because it's a JSON tree already. throw new Error(e); } } else { contentAsText = content.toString(); } } return contentAsText; }