@Override public ImmutableFxSwapConvention build() { return new ImmutableFxSwapConvention( currencyPair, name, spotDateOffset, businessDayAdjustment); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ImmutableFxSwapConvention beanToCopy) { this.currencyPair = beanToCopy.getCurrencyPair(); this.name = beanToCopy.name; this.spotDateOffset = beanToCopy.getSpotDateOffset(); this.businessDayAdjustment = beanToCopy.businessDayAdjustment; }
/** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static ImmutableFxSwapConvention.Builder builder() { return new ImmutableFxSwapConvention.Builder(); }
public void test_builder() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.builder() .currencyPair(EUR_USD) .name("EUR::USD") .spotDateOffset(PLUS_TWO_DAYS) .businessDayAdjustment(BDA_FOLLOW) .build(); assertEquals(test.getName(), "EUR::USD"); assertEquals(test.getCurrencyPair(), EUR_USD); assertEquals(test.getSpotDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getBusinessDayAdjustment(), BDA_FOLLOW); }
/** * Obtains a template based on the specified period and convention. * <p> * The near date is equal to the spot date. * The period from the spot date to the far date is specified * <p> * For example, a '6M' FX swap has a near leg on the spot date and a period from spot to the far date of 6 months * * @param periodToFar the period between the spot date and the far date * @param convention the market convention * @return the template */ public static FxSwapTemplate of(Period periodToFar, FxSwapConvention convention) { return FxSwapTemplate.builder() .periodToNear(Period.ZERO) .periodToFar(periodToFar) .convention(convention).build(); }
public void coverage() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); coverImmutableBean(test); ImmutableFxSwapConvention test2 = ImmutableFxSwapConvention.builder() .name("GBP/USD") .currencyPair(GBP_USD) .spotDateOffset(PLUS_ONE_DAY) .businessDayAdjustment(BDA_MODFOLLOW) .build(); coverBeanEquals(test, test2); }
/** * Obtains a convention based on the specified currency pair and spot date offset. * <p> * Use the {@linkplain #builder() builder} for unusual conventions. * * @param currencyPair the currency pair associated to the convention * @param spotDateOffset the spot date offset * @return the convention */ public static ImmutableFxSwapConvention of(CurrencyPair currencyPair, DaysAdjustment spotDateOffset) { return ImmutableFxSwapConvention.builder() .currencyPair(currencyPair) .spotDateOffset(spotDateOffset) .build(); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(FxSwapTemplate beanToCopy) { this.periodToNear = beanToCopy.getPeriodToNear(); this.periodToFar = beanToCopy.getPeriodToFar(); this.convention = beanToCopy.getConvention(); }
@Override public String toString() { return getName(); }
/** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static FxSwapTemplate.Builder builder() { return new FxSwapTemplate.Builder(); }
@Override public FxSwapTemplate build() { return new FxSwapTemplate( periodToNear, periodToFar, convention); }
/** * Gets the currency pair of the template. * * @return the currency pair */ public CurrencyPair getCurrencyPair() { return convention.getCurrencyPair(); }
@Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { metaProperty(propertyName); if (quiet) { return; } throw new UnsupportedOperationException("Property cannot be written: " + propertyName); }
private FxSwapTemplate( Period periodToNear, Period periodToFar, FxSwapConvention convention) { JodaBeanUtils.notNull(periodToNear, "periodToNear"); JodaBeanUtils.notNull(periodToFar, "periodToFar"); JodaBeanUtils.notNull(convention, "convention"); this.periodToNear = periodToNear; this.periodToFar = periodToFar; this.convention = convention; validate(); }
/** * Obtains a template based on the specified periods and convention. * <p> * Both the period from the spot date to the near date and far date are specified. * <p> * For example, a '3M x 6M' FX swap has a period from spot to the start date of 3 months and * a period from spot to the far date of 6 months * * @param periodToNear the period between the spot date and the near date * @param periodToFar the period between the spot date and the far date * @param convention the market convention * @return the template */ public static FxSwapTemplate of(Period periodToNear, Period periodToFar, FxSwapConvention convention) { return FxSwapTemplate.builder() .periodToNear(periodToNear) .periodToFar(periodToFar) .convention(convention).build(); }
/** * Returns a builder that allows this bean to be mutated. * @return the mutable builder, not null */ public Builder toBuilder() { return new Builder(this); }
/** * Returns a builder that allows this bean to be mutated. * @return the mutable builder, not null */ public Builder toBuilder() { return new Builder(this); }
public void test_builder_insufficientInfo() { assertThrowsIllegalArg(() -> FxSwapTemplate.builder().convention(CONVENTION).build()); assertThrowsIllegalArg(() -> FxSwapTemplate.builder().periodToNear(NEAR_PERIOD).build()); assertThrowsIllegalArg(() -> FxSwapTemplate.builder().periodToFar(FAR_PERIOD).build()); }
@Override public ImmutableFxSwapConvention.Builder builder() { return new ImmutableFxSwapConvention.Builder(); }
@Override public FxSwapTemplate.Builder builder() { return new FxSwapTemplate.Builder(); }