-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[wip] Make Context API non nullable #780
Conversation
smaldini
commented
Aug 3, 2017
•
edited
edited
- add hasKey : boolean
- add getOrEmpty : Optional
Codecov Report
@@ Coverage Diff @@
## master #780 +/- ##
============================================
+ Coverage 82.5% 82.85% +0.35%
- Complexity 3026 3145 +119
============================================
Files 312 314 +2
Lines 25439 25710 +271
Branches 4752 4831 +79
============================================
+ Hits 20989 21303 +314
+ Misses 2953 2928 -25
+ Partials 1497 1479 -18
Continue to review full report at Codecov.
|
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.
2 concerns with that approach:
- is throwing on a get with bad key a good idea at all? think about the usage patterns and the try/catch or if(hasKey) this implies? granted there is a getOrEmpty but... I think I'd leave
get
as Nullable. - why remove
getOrDefault
at all? It is useful IMO, as much as getOrEmpty...
If you decide to keep the exceptions, at least document them in the javadocs
It's wip but the point here is a get(...) that would return null would do so indefinitely. Context is immutable, a null key will never turn non null for a given ctx. User can still query presence of a key with hasKey or getOrEmpty (which superseed getOrDefault via Optionsl.orElse), |
got it, wasn't sure what would be the most complicated to use between a nullable get or a throwing fair point on |
@smaldini was thinking about:
|
note on |
- rename contextStart to subscriberContext - remove contextGet in favor of existing handle - make most of Context API non nullable - add hasKey : boolean - add getOrEmpty : Optional<T>
- add Context.of static factory methods for cardinalities 1-5 - add specific implementations for cardinalities 1-5 - add Context#putAll(Context) - fix isEmpty to also detect (internal only) instances of Context0 - add tests for Context0-ContextN - clarify javadoc of `get` - remove unneeded Nullable imports / annotations test the Context.of methods + javadoc fix isEmpty detecting Context0 instances (internal only) + test Context0 clarify javadoc of get (throws rather than returning null) remove unneeded Nullable annotations/imports
5ee721e
to
bac409c
Compare
- rename contextStart to subscriberContext - remove contextGet in favor of existing handle - make most of Context API non nullable - add hasKey : boolean - add getOrEmpty : Optional<T>
- add Context.of static factory methods for cardinalities 1-5 - add specific implementations for cardinalities 1-5 - add Context#putAll(Context) - fix isEmpty to also detect (internal only) instances of Context0 - add tests for Context0-ContextN - clarify javadoc of `get` - remove unneeded Nullable imports / annotations test the Context.of methods + javadoc fix isEmpty detecting Context0 instances (internal only) + test Context0 clarify javadoc of get (throws rather than returning null) remove unneeded Nullable annotations/imports