Last active
July 30, 2017 18:46
-
-
Save nachivpn/7ef92059eaebe57444c55e2ceba78a96 to your computer and use it in GitHub Desktop.
getComponentPriceWDisc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//return component price from Either<Exception, Component>, but if any step fails, return exception which occured | |
public Either<Exception,Double> getComponentPrice(Either<Exception, Component> response){ | |
return response | |
//extract component id | |
.fmap(result -> result.getId()) | |
//find price | |
.bind(this::findOriginalPrice) | |
//apply discount if applicable | |
.fmap(this::discountedPrice); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment