-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added qualities for delegating functions #83
Added qualities for delegating functions #83
Conversation
* @param delegateResult delegate result, no impact on quality, but must be a valid result that does not cause an excaption | ||
* @param delegateArgumentQuality quality verifying the delegate argument | ||
*/ | ||
public DelegateMapsArgument(In outerArgument, Out delegateResult, Quality<DelegateIn> delegateArgumentQuality) { |
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.
In general a delegate Quality
s should always be contravariant, i.e. passed as Quality<? super DelegateIn>
* +-----------------------------------------------------------------------------------+ | ||
* | DelegateFunction | | ||
* | +------------------------------------------+ | | ||
* | OuterArgument ----> | DelegateArgument -----> DelegateResult | ---> OuterResult | |
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.
>
needs to be encoded to >
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
============================================
- Coverage 96.94% 96.91% -0.03%
- Complexity 598 606 +8
============================================
Files 156 158 +2
Lines 1308 1330 +22
Branches 46 46
============================================
+ Hits 1268 1289 +21
- Misses 34 35 +1
Partials 6 6
☔ View full report in Codecov by Sentry. |
* @param delegateResult delegate result, no impact on quality, but must be a valid result that does not cause an excaption | ||
* @param delegateArgumentQuality quality verifying the delegate argument | ||
*/ | ||
public MapsArgument(In outerArgument, Out delegateResult, Quality<DelegateIn> delegateArgumentQuality) { |
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.
the delegateArgumentQuality
argument should also be of type Quality<? super DelegateIn>
, not just the member ;-)
final AtomicReference<DelegateIn> delegateValueReference = new AtomicReference<>(); | ||
final Function<In, Out> actualFunction = candidate.apply(delegateValue -> { | ||
delegateValueReference.set(delegateValue); | ||
return mDelegateResult; |
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.
let's take the shortcut here and throw a custom Error
. Having to provide a return value makes this more cumbersome.
return mDelegateResult; | ||
}); | ||
|
||
actualFunction.apply(mOuterArgument); |
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.
What happens when the outer function doesn't call the delegate at all? I'd like to see this covered by the Quality
.
*/ | ||
public MapsArgument(In outerArgument, Quality<? super DelegateIn> delegateArgumentQuality) | ||
{ | ||
this.mOuterArgument = outerArgument; |
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.
Remove this.
, and remove @param
annotations
* | +------------------------------------------+ | | ||
* | OuterArgument ----> | DelegateArgument -----> DelegateResult | ---> OuterResult | | ||
* | +------------------------------------------+ | | ||
* +-----------------------------------------------------------------------------------+ |
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 example
private final Out mDelegateResult; | ||
private final Quality<? super Function<In, Out>> mDelegate; | ||
|
||
public ResultOf(Out delegateResult, Quality<Function<In, Out>> delegate) |
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 ...super...
No description provided.