Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 1-based
Month[De]serializer
enabled withJavaTimeFeature.ONE_BASED_MONTHS
option #292Add 1-based
Month[De]serializer
enabled withJavaTimeFeature.ONE_BASED_MONTHS
option #292Changes from 5 commits
4903c75
ff079f2
fcfc0da
210333c
014b98b
aa47cd7
a2f7f91
6e27079
ce4504a
43ffd27
e042c24
b194054
fe3f568
8211306
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Probably not needed?
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.
Shouldn't this only need to be returned if
_oneBasedMonths
is true? That might simplify handling a bit when there are fewer checks.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.
@cowtowncoder - it's mostly about the naming and meaning of the classes. If we do it like this, perhaps it's better to rename the deserializer from
MonthDeserializer
toOneBasedMonthDeserializer
and make it always updated the value returned by the delegate (without checking the_oneBasedMonths
flag -- and move the check here).What do you think?
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.
Yes, I think that makes sense -- I like explicit naming.
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.
Add
@since 2.17
in Javadoc here tooThere 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.
I think I would actually change this so that if
! _enableOneBaseMonths
, or current token notJsonToken.VALUE_NUMBER_INT
(and I guess "Stringified" number), just calldelegate.deserialize()
and return value you get.This is based on understanding that, I think, String name like
"FEBRUARY"
should NOT be changed toJANUARY
? At least to me 0- vs 1-based logic only applies to numeric (and stringified numbers) case, not to textual.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.
Ok, couple of things:
parser.getText()
will return contents, so no quotes around it, can leave those out.And make sure to create pre-compiled
Pattern
as static member of class: otherwise RegEx state machine is re-create for every call... and that's pretty expensive (and more importantly easily avoidable :) ).