Skip to content

Instantly share code, notes, and snippets.

@nachivpn
Last active July 30, 2017 18:46
Show Gist options
  • Save nachivpn/7ef92059eaebe57444c55e2ceba78a96 to your computer and use it in GitHub Desktop.
Save nachivpn/7ef92059eaebe57444c55e2ceba78a96 to your computer and use it in GitHub Desktop.
getComponentPriceWDisc.java
//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