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

Make Money::with less restritive to support interop with others implementations #113

Open
DiegoCoronel opened this issue Jan 3, 2019 · 0 comments

Comments

@DiegoCoronel
Copy link

I had a situation where I needed to implement my own MonetaryAmount (decorated Money) and now Im not able to integrate my code smooth with Money::with because theres a forced cast to Money. Is it possible to relax this and return a MonetaryAmount ?

 @Override
    public Money with(MonetaryOperator operator) { // <-- Can you return MonetaryAmount ?
        Objects.requireNonNull(operator);
        try {
            return Money.class.cast(operator.apply(this)); // <-- Can you relax this code ?
        } catch (MonetaryException e) {
            throw e;
        } catch (Exception e) {
            throw new MonetaryException("Operator failed: " + operator, e);
        }
    }

Initially I had open this issue in JavaMoney/jsr354-ri#190 and @marschall suggested to discuss it here.

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

No branches or pull requests

1 participant