-
Notifications
You must be signed in to change notification settings - Fork 209
Make comparing status more convenient. #187
Conversation
👍 |
1 similar comment
👍 |
Codecov Report
@@ Coverage Diff @@
## master #187 +/- ##
============================================
+ Coverage 69.95% 70.04% +0.08%
- Complexity 0 681 +681
============================================
Files 143 143
Lines 2949 2951 +2
Branches 239 171 -68
============================================
+ Hits 2063 2067 +4
+ Misses 840 838 -2
Partials 46 46
Continue to review full report at Codecov.
|
👍 |
👍 I've made this mistake often |
* @return true if code of this equals code of statusType | ||
*/ | ||
default boolean equalCode(StatusType statusType) { | ||
return statusType != null && code() == statusType.code(); |
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.
Would rather have this throw NPE... Fail early!
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.
I would agree, I think. @rydenius, is there a reason to expect/permit users to pass in a null statusType
to this method?
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.
Fixed now.
* @return true if family of this equals family of statusType | ||
*/ | ||
default boolean equalFamily(StatusType statusType) { | ||
return statusType != null && family() == statusType.family(); |
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.
Same
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.
Fixed now.
More than once I have seen code like this fail:
or
because the status of the response has a different reason phrase. The current solution would be to use
This small patch would simplify this check and also signal to developers that regular equals method might not be what you want to use.