Remove Payment Period

Hi team,

I have a resolved interest rate swap trade.

I would like to remove the first floating payment period on leg 2 and keep the remaining payments.

Looks like the remove method is deprecated:

What’s the best way to do this?

Thank you


As the beans are immutable, you have to make a copy with the value changed, something like:

var leg1 = resolvedswap.getProduct().getLegs().get(0);
var leg2 = resolvedswap.getProduct().getLegs().get(1);
resolvedSwap = resolvedSwap.toBuilder()
        .paymentPeriods(leg2.getPaymentPeriods().subList(1, leg2.getPaymentPeriods().size()))

(this might not compile as I wrote it in the forum, but is the general approach to editing a tree of immutable beans)

1 Like