-
Notifications
You must be signed in to change notification settings - Fork 12
Add Enum and Boolean fields validators #190
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
Conversation
Current coverage is 78.15% (diff: 96.96%)@@ master #190 diff @@
==========================================
Files 130 132 +2
Lines 4709 4733 +24
Methods 0 0
Messages 0 0
Branches 518 521 +3
==========================================
+ Hits 3678 3699 +21
- Misses 937 939 +2
- Partials 94 95 +1
|
alexander-yevsyukov
left a comment
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.
Please see my comments. Some minor changes are required.
| * @author Dmitry Kashcheiev | ||
| */ | ||
| /* package */ class BooleanFieldValidator extends FieldValidator<Boolean> { | ||
|
|
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.
Please remove excessive empty line.
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.
done
|
|
||
| @Override | ||
| protected boolean isValueNotSet(Boolean value) { | ||
| // Boolean field can't be determined if it set or not, because protobuf 'false' value and 'no value' are the 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.
A Javadoc would be more appropriate here.
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.
done
| @Override | ||
| protected boolean isValueNotSet(Boolean value) { | ||
| // Boolean field can't be determined if it set or not, because protobuf 'false' value and 'no value' are the same | ||
| return false; |
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.
Please test this. Do you have a Codecov browser plug-in installed?
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.
done
|
|
||
| @Override | ||
| protected boolean isValueNotSet(Descriptors.EnumValueDescriptor value) { | ||
| return value.getNumber() == 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.
Have final boolean result field immediately before return. This way it's easier to debug, when 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.
added final boolean result also updated for other files to look the same
| final List<ConstraintViolation> violations = super.validate(); | ||
| return violations; | ||
| } | ||
|
|
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 don't need an empty line here.
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.
done
| /** | ||
| * Returns {@code true} if the field has required attribute or validation is strict. | ||
| */ | ||
| protected boolean isRequiredField() { |
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.
Please have result variable here.
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.
done
| } | ||
|
|
||
| /** | ||
| * Boolean field can't be determined if it set or not, because protobuf 'false' value and 'no value' are the 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.
Please have dot at the end of the sentence. While we are here, I'd say that it would be better to say that
”In Protobuf there is no way to tell if the value is {@code false} or was not set.”
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
alexander-yevsyukov
left a comment
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.
Please change the Javadoc per my recent comment. In the rest LGTM.
alexander-yevsyukov
left a comment
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
No description provided.