String (@NotNull Element element, @NotNull String defaultText) { List<Content> content = element.getContent(); int size = content.size(); StringBuilder builder = null; for (int i = 0; i < size; i++) { Content child = content.get(i); if (child instanceof Text) { String value = child.getValue(); if (builder == null && i == (size - 1)) { return value; } if (builder == null) { builder = new StringBuilder(); } builder.append(value); } } return builder == null ? defaultText : builder.toString(); }