-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Type Check to Strict Extractor #34
Conversation
b6356a5
to
f6893e7
Compare
*/ | ||
public PathExtractorBuilder<T> withSearchPath(final List<PathComponent> pathComponents, | ||
final BiFunction<IonReader, T, Integer> callback) { | ||
return withSearchPath(pathComponents, callback, new String[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well use a constant for new String[0]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually a change from the other PR that I accidentally included here. I addressed it in that PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* The type check is performed _after_ any callbacks registered for the current path and | ||
* _before_ any child matches are attempted. | ||
*/ | ||
public PathExtractor<T> buildStrict(final boolean strictTyping) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Suggestion) Maybe we can make this private and have a buildStrictWithTypeCheck
. It just sounds redundant to say PathExtractorBuilder.buildStrict(true)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea.. but it means that on the call-site I don't need to add branches if i already have a boolean flag.
Search paths on field names, indexed elements or wildcards imply an expectation for container types. Before this change, a search path looking for a field would simply not be invoked if the data was not a struct. With this change, users can elect to have an Exception thrown when data does not meet the implied type expectations of their paths. The type check is performed after any callback for the parent itself: that is not known to be mistyped by the paths. It is only implemented for the "strict" matcher and the change to the API reflects that.
f6893e7
to
b6cebc1
Compare
Search paths on field names, indexed elements or wildcards imply an
expectation for container types. Before this change, a search path
looking for a field would simply not be invoked if the data was not
a struct. With this change, users can elect to have an Exception thrown
when data does not meet the implied type expectations of their paths.
The type check is performed after any callback for the parent itself:
that is not known to be mistyped by the paths.
It is only implemented for the "strict" matcher and the change to the
API reflects that.