/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(FraTemplate beanToCopy) { this.periodToStart = beanToCopy.getPeriodToStart(); this.periodToEnd = beanToCopy.getPeriodToEnd(); this.convention = beanToCopy.getConvention(); }
@Override public FraTemplate build() { preBuild(this); return new FraTemplate( periodToStart, periodToEnd, convention); }
/** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static ImmutableFraConvention.Builder builder() { return new ImmutableFraConvention.Builder(); }
public void test_of_index() { ImmutableFraConvention test = ImmutableFraConvention.of(GBP_LIBOR_3M); assertEquals(test.getIndex(), GBP_LIBOR_3M); assertEquals(test.getName(), GBP_LIBOR_3M.getName()); assertEquals(test.getCurrency(), GBP); assertEquals(test.getSpotDateOffset(), GBP_LIBOR_3M.getEffectiveDateOffset()); assertEquals(test.getBusinessDayAdjustment(), BDA_MOD_FOLLOW); assertEquals(test.getPaymentDateOffset(), DaysAdjustment.NONE); assertEquals(test.getFixingDateOffset(), GBP_LIBOR_3M.getFixingDateOffset()); assertEquals(test.getDayCount(), ACT_365F); assertEquals(test.getDiscounting(), ISDA); // ensure other factories match assertEquals(FraConvention.of(GBP_LIBOR_3M), test); assertEquals(FraConventions.of(GBP_LIBOR_3M), test); }
public void test_builder_defaults() { FraTemplate test = FraTemplate.builder() .periodToStart(Period.ofMonths(2)) .convention(FRA_GBP_LIBOR_3M) .build(); assertEquals(test.getPeriodToStart(), Period.ofMonths(2)); assertEquals(test.getPeriodToEnd(), Period.ofMonths(5)); // defaulted assertEquals(test.getConvention(), FRA_GBP_LIBOR_3M); }
public void test_builder_insufficientInfo() { assertThrowsIllegalArg(() -> FraTemplate.builder().convention(FRA_GBP_LIBOR_3M).build()); assertThrowsIllegalArg(() -> FraTemplate.builder().periodToStart(Period.ofMonths(2)).build()); }
/** * Obtains a convention based on the specified index. * <p> * The standard market convention for a FRA is based exclusively on the index. * This creates an instance that contains the index. * The instance is not dereferenced using the {@code FraConvention} name, as such * the result of this method and {@link FraConvention#of(IborIndex)} can differ. * <p> * Use the {@linkplain #builder() builder} for unusual conventions. * * @param index the index, the market convention values are extracted from the index * @return the convention */ public static ImmutableFraConvention of(IborIndex index) { return ImmutableFraConvention.builder() .index(index) .build(); }
public void test_builder_noIndex() { assertThrowsIllegalArg(() -> ImmutableFraConvention.builder() .spotDateOffset(NEXT_SAME_BUS_DAY) .build()); }
/** * Obtains a convention based on the specified index. * <p> * This uses the index name to find the matching convention. * By default, this will always return a convention, however configuration may be added * to restrict the conventions that are registered. * * @param index the index, from which the index name is used to find the matching convention * @return the convention * @throws IllegalArgumentException if no convention is registered for the index */ public static FraConvention of(IborIndex index) { return FraConvention.of(index); }
@Override public FraConvention lookup(String name) { FraConvention value = BY_NAME.get(name); if (value == null) { FraConvention created = createByName(name); if (created != null) { String correctName = created.getName(); value = BY_NAME.computeIfAbsent(correctName, k -> created); BY_NAME.putIfAbsent(correctName.toUpperCase(Locale.ENGLISH), value); } } return value; }
@Override public String toString() { return getName(); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ImmutableFraConvention beanToCopy) { this.index = beanToCopy.getIndex(); this.name = beanToCopy.name; this.currency = beanToCopy.currency; this.dayCount = beanToCopy.dayCount; this.spotDateOffset = beanToCopy.spotDateOffset; this.businessDayAdjustment = beanToCopy.businessDayAdjustment; this.fixingDateOffset = beanToCopy.fixingDateOffset; this.paymentDateOffset = beanToCopy.paymentDateOffset; this.discounting = beanToCopy.discounting; }
/** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static FraTemplate.Builder builder() { return new FraTemplate.Builder(); }
@Override public ImmutableFraConvention build() { return new ImmutableFraConvention( index, name, currency, dayCount, spotDateOffset, businessDayAdjustment, fixingDateOffset, paymentDateOffset, discounting); }
/** * 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); }
@Override public ImmutableFraConvention.Builder builder() { return new ImmutableFraConvention.Builder(); }
@Override public FraTemplate.Builder builder() { return new FraTemplate.Builder(); }