Skip to content

Commit 501f955

Browse files
authored
Update JsonNode.java (#4476)
1 parent 856c80b commit 501f955

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/fasterxml/jackson/databind/JsonNode.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -631,17 +631,18 @@ public byte[] binaryValue() throws IOException {
631631
public abstract String asText();
632632

633633
/**
634-
* Method similar to {@link #asText()}, except that it will return
635-
* <code>defaultValue</code> in cases where null value would be returned;
636-
* either for missing nodes (trying to access missing property, or element
637-
* at invalid item for array) or explicit nulls.
634+
* Returns the text value of this node or the provided {@code defaultValue} if this node
635+
* does not have a text value. Useful for nodes that are {@link MissingNode} or
636+
* {@link com.fasterxml.jackson.databind.node.NullNode}, ensuring a default value is returned instead of null or missing indicators.
637+
*
638638
*<p>
639639
* NOTE: deprecated since 2.17 because {@link #asText()} very rarely returns
640640
* {@code null} for any node types -- in fact, neither {@link MissingNode}
641641
* nor {@code NullNode} return {@code null} from {@link #asText()}.
642642
*
643+
* @param defaultValue The default value to return if this node's text value is absent.
644+
* @return The text value of this node, or defaultValue if the text value is absent.
643645
* @since 2.4
644-
*
645646
* @deprecated Since 2.17, to be removed from 3.0
646647
*/
647648
@Deprecated // @since 2.17

0 commit comments

Comments
 (0)