-
Notifications
You must be signed in to change notification settings - Fork 23
Experimental feature for unboxing. #122
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #122 +/- ##
===========================================
- Coverage 99.45% 99.3% -0.16%
+ Complexity 349 335 -14
===========================================
Files 43 41 -2
Lines 739 718 -21
Branches 22 22
===========================================
- Hits 735 713 -22
- Partials 4 5 +1
|
Nice. Does it work with concrete types or only interfaces? I'm thinking people would really like to use this for mocks, which are frequently (with Mockito at least) concrete types. Still mulling over the There may also be some sneaky tricks to even avoid passing in that |
The inbox function as provided can be used to surround any supplier, of which both let and junitMixin are such... but we could provide overloads to wrap it further. It can ONLY work for interfaces. This is a technical constraint to do with dynamic proxies, but also makes sense if you think about how concrete types can have accessible instance variables and multiple constructors, which even Mockito has limitations over. The type must be specified in the call because the stuff you mentioned about inferring type only works for generic types themselves, not for actual Class objects. In other words, to know at run time the interface to supply, you need a Class object. Even Mockito.mock requires a class object as input. |
I've extended my POC to have the equivalent of this - I reverse the order of parameters from the above, because that's what felt natural, but it's easily refactored. I did it for How does it look? |
43d58f7
to
456ffa5
Compare
Understood ✅ . A couple thoughts:
|
So, I should remove the overloads of let and junitmixin? It is easy to check if the passed in class is an interface. Naming the method was hard. It's an auto get or an unwrapper or a de supplier or... nothing sounded good. Accessor? |
This is what I had in mind for #103.
@greghaskins - does it majorly suck, or does it add value?