(note: alternative take on #893)
Accessing numeric value from JsonParser can be done either using typed accessors (getLongValue()) or using generic Number JsonParser.getNumberValue(). But in both of these cases access forces decoding of the actual numeric value.
But there are cases where it would be nice to only get actual Number if it has already been decoded; otherwise return String representation of the number.
Although there is no super nice way in Java to support "either" type, I think in this case it is fine to simply indicate type as Object and let caller do type-casting: main initial user will be TokenBuffer class in jackson-databind; and it will further use integer-or-floating-point distinction (wrt JsonParser.currentToken()) to figure out possible types.
Base implementation in JsonParser, for backwards compatibility, should be to simple call getNumberValue(), return that: subtypes that support deferred parsing then need to override this.
(note: alternative take on #893)
Accessing numeric value from
JsonParsercan be done either using typed accessors (getLongValue()) or using genericNumber JsonParser.getNumberValue(). But in both of these cases access forces decoding of the actual numeric value.But there are cases where it would be nice to only get actual
Numberif it has already been decoded; otherwise returnStringrepresentation of the number.Although there is no super nice way in Java to support "either" type, I think in this case it is fine to simply indicate type as
Objectand let caller do type-casting: main initial user will beTokenBufferclass injackson-databind; and it will further use integer-or-floating-point distinction (wrtJsonParser.currentToken()) to figure out possible types.Base implementation in
JsonParser, for backwards compatibility, should be to simple callgetNumberValue(), return that: subtypes that support deferred parsing then need to override this.