FasterXML / FasterXML/jackson3-dev

Change `JsonNode.asXxx()` methods with no defaults to throw exception; add in `TreeNode`

Aperta
#6 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
functionality-change
Lingua principale
Nessun dato sulla lingua
Stelle
6
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Currently various `asXxx()` methods (like, say, `asInt()`) return default value (like `0` for `int`) in case where no conversion is possible. But it would usually be better to instead throw an exception since there are already variants that allow passing of default value to return in invalid case.
Throwing exception instead would allow caller to avoid potentially odd and unhelpful coercions into default value. Given existence of alternatives with defaults no functionality would be removed.

In addition to this change it would make sense to add (demote) these methods in `TreeNode`, esp. since we can use Java 8 default methods for interfaces.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.