Add enhanced versions of
getObject / getArray / getPrimitive
named
tryGetObject / tryGetArray / tryGetPrimitive
For example, getObject produces an ObjectElement. tryGetObject would produce an Optional<ObjectElement>, so that short-circuiting substitution can be done.
Could also be covered using sneaky types so that an empty-projected ObjectElement could have asOptional() called on it and return EMPTY, or getObjectOr taking an object key and an object supplier. But I think tryGetObject and giving users access to the whole toolbox of Optional methods is the best value for the engineering effort.
Add enhanced versions of
getObject
/getArray
/getPrimitive
namedtryGetObject
/tryGetArray
/tryGetPrimitive
For example, getObject produces an ObjectElement. tryGetObject would produce an Optional<ObjectElement>, so that short-circuiting substitution can be done.
Could also be covered using sneaky types so that an empty-projected ObjectElement could have asOptional() called on it and return EMPTY, or getObjectOr taking an object key and an object supplier. But I think tryGetObject and giving users access to the whole toolbox of Optional methods is the best value for the engineering effort.