AbstractNode { @Nonnull public String getAsString(@Nonnull String fieldName) { DockerCloudUtils.requireNonNull(fieldName, "Field name cannot be null."); checkObject(); JsonNode value = node.get(fieldName); if (value == null || !value.isTextual()) { throw new NodeProcessingException("Child field not found or is not a string value node: " + node + " / " + fieldName); } return value.asText(); } AbstractNode(JsonNode node); @Nonnull List<N> getArrayValues(); @Nonnull Map<String, N> getObjectValues(); @Nonnull N getObject(@Nonnull String fieldName); N getObject(@Nonnull String fieldName, @Nullable N def); N getArray(@Nonnull String fieldName); N getArray(@Nonnull String fieldName, @Nullable N def); int getAsInt(@Nonnull String fieldName); int getAsInt(@Nonnull String fieldName, int def); BigInteger getAsBigInt(@Nonnull String fieldName); BigInteger getAsBigInt(@Nonnull String fieldName, BigInteger def); long getAsLong(@Nonnull String fieldName); boolean getAsBoolean(@Nonnull String fieldName); Boolean getAsBoolean(@Nonnull String fieldName, @Nullable Boolean def); @Nonnull String getAsString(@Nonnull String fieldName); String getAsString(@Nonnull String fieldName, @Nullable String def); @Nonnull String getAsString(); boolean isNull(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void getAsString() { AbstractNode<N> node = parentWithChildString("A"); assertThat(node.getAsString("child")).isEqualTo("A"); assertThat(node.getAsString("unknownChild", "B")).isEqualTo("B"); }