@@ -103,6 +103,27 @@ public JsonParser.NumberType numberType() {
103
103
return null ;
104
104
}
105
105
106
+ /*
107
+ /**********************************************************
108
+ /* Other traversal
109
+ /**********************************************************
110
+ */
111
+
112
+ @ Override
113
+ public <T extends JsonNode > T withObject (JsonPointer ptr ) {
114
+ if (!isObject ()) {
115
+ // To avoid abstract method, base implementation just fails
116
+ _reportWrongNodeType ("Can only call `withObject()` on `ObjectNode`, not `%s`" ,
117
+ getClass ().getName ());
118
+ }
119
+ return _withObject (ptr , ptr );
120
+ }
121
+
122
+ protected <T extends JsonNode > T _withObject (JsonPointer origPtr ,
123
+ JsonPointer currentPTr ) {
124
+ return null ;
125
+ }
126
+
106
127
/*
107
128
/**********************************************************
108
129
/* JsonSerializable
@@ -140,5 +161,18 @@ public String toString() {
140
161
public String toPrettyString () {
141
162
return InternalNodeMapper .nodeToPrettyString (this );
142
163
}
143
- }
144
164
165
+ /*
166
+ /**********************************************************
167
+ /* Other helper methods for subtypes
168
+ /**********************************************************
169
+ */
170
+
171
+ /**
172
+ * Helper method that throws {@link UnsupportedOperationException} as a result of
173
+ * this node being of wrong type
174
+ */
175
+ protected <T > T _reportWrongNodeType (String msgTemplate , Object ...args ) {
176
+ throw new UnsupportedOperationException (String .format (msgTemplate , args ));
177
+ }
178
+ }
0 commit comments