Skip to content
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 converted to result method on FxConvertible #2643

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

James-OpenGamma
Copy link
Contributor

No description provided.

@James-OpenGamma James-OpenGamma requested review from jodastephen, a team, yukiiwashita, skitini, Neelesh99 and hsaleem06 and removed request for a team April 24, 2024 16:21
@@ -239,6 +245,19 @@ public void test_convertedTo_rateProvider() {
assertThat(CCY_AMOUNT.convertedTo(CCY1, provider)).isEqualTo(CCY_AMOUNT);
}

@Test
public void test_convertedToResult_failure() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for the success case

* @return the result of the converted instance, which should be expressed in the specified currency
*/
public default Result<R> convertedToResult(Currency resultCurrency, FxRateProvider rateProvider) {
return Result.of(() -> convertedTo(resultCurrency, rateProvider));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this implementation, I'm struggling to justify adding the method,. Bear in mind that the method becomes public on a large number of implementation classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have Result.of(() -> ...convertedTo) littered around most of the models, as we want to avoid any hard errors in a calculation, this method would help clean things up a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants