/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(SwapLegAmount beanToCopy) { this.amount = beanToCopy.getAmount(); this.payReceive = beanToCopy.getPayReceive(); this.type = beanToCopy.getType(); this.currency = beanToCopy.getCurrency(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -1413853096: // amount return ((SwapLegAmount) bean).getAmount(); case -885469925: // payReceive return ((SwapLegAmount) bean).getPayReceive(); case 3575610: // type return ((SwapLegAmount) bean).getType(); case 575402001: // currency return ((SwapLegAmount) bean).getCurrency(); } return super.propertyGet(bean, propertyName, quiet); }
public void test_of() { SwapPaymentPeriod pp = mock(SwapPaymentPeriod.class); when(pp.getCurrency()).thenReturn(Currency.GBP); ResolvedSwapLeg leg = ResolvedSwapLeg.builder() .type(SwapLegType.FIXED) .payReceive(PayReceive.PAY) .paymentPeriods(pp) .build(); SwapLegAmount legAmount = SwapLegAmount.of(leg, CurrencyAmount.of(Currency.GBP, 10)); SwapLegAmount test = legAmount.convertedTo(Currency.USD, FxRate.of(Currency.GBP, Currency.USD, 1.6)); assertThat(test.getAmount().getCurrency()).isEqualTo(Currency.USD); assertThat(test.getAmount().getAmount()).isEqualTo(16.0); assertThat(test.getPayReceive()).isEqualTo(legAmount.getPayReceive()); assertThat(test.getType()).isEqualTo(legAmount.getType()); assertThat(test.getCurrency()).isEqualTo(legAmount.getCurrency()); }
public void convertedTo() { SwapLegAmount legAmount = SwapLegAmount.builder() .amount(CurrencyAmount.of(Currency.GBP, 10)) .payReceive(PayReceive.PAY) .type(SwapLegType.FIXED) .currency(Currency.GBP) .build(); SwapLegAmount convertedAmount = legAmount.convertedTo(Currency.USD, FxRate.of(Currency.GBP, Currency.USD, 1.6)); assertThat(convertedAmount.getAmount().getCurrency()).isEqualTo(Currency.USD); assertThat(convertedAmount.getAmount().getAmount()).isEqualTo(16.0); assertThat(convertedAmount.getPayReceive()).isEqualTo(legAmount.getPayReceive()); assertThat(convertedAmount.getType()).isEqualTo(legAmount.getType()); assertThat(convertedAmount.getCurrency()).isEqualTo(legAmount.getCurrency()); }