/** * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.convention; import java.util.Map; import org.joda.beans.Bean; import org.joda.beans.BeanBuilder; import org.joda.beans.BeanDefinition; import org.joda.beans.JodaBeanUtils; import org.joda.beans.MetaProperty; import org.joda.beans.Property; import org.joda.beans.PropertyDefinition; import org.joda.beans.impl.direct.DirectBeanBuilder; import org.joda.beans.impl.direct.DirectMetaProperty; import org.joda.beans.impl.direct.DirectMetaPropertyMap; import com.opengamma.core.convention.ConventionType; import com.opengamma.financial.convention.daycount.DayCount; import com.opengamma.id.ExternalId; import com.opengamma.id.ExternalIdBundle; import com.opengamma.util.ArgumentChecker; import com.opengamma.util.money.Currency; import com.opengamma.util.time.Tenor; /** * Convention for a fixed leg based on roll date adjuster. This convention should be used only in a IMMSwapConvention. */ @BeanDefinition public class FixedLegRollDateConvention extends FinancialConvention { /** * Type of the convention. */ public static final ConventionType TYPE = ConventionType.of("FixedLegRollDate"); /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The payment tenor. */ @PropertyDefinition(validate = "notNull") private Tenor _paymentTenor; /** * The day count for the coupon payments. */ @PropertyDefinition(validate = "notNull") private DayCount _dayCount; /** * The currency. */ @PropertyDefinition(validate = "notNull") private Currency _currency; /** * The region calendar. */ @PropertyDefinition(validate = "notNull") private ExternalId _regionCalendar; /** * The stub type. */ @PropertyDefinition(validate = "notNull") private StubType _stubType; /** * Whether the notional exchanged at the start and at the end. */ @PropertyDefinition private boolean _isExchangeNotional; /** * The payment lag in days. */ @PropertyDefinition private int _paymentLag; /** * Creates an instance. */ protected FixedLegRollDateConvention() { super(); } /** * Creates an instance. * * @param name the name of the convention, not null * @param externalIdBundle the external identifiers for this convention, not null * @param paymentTenor the payment tenor, not null * @param dayCount the day-count, not null * @param currency the currency, not null * @param regionCalendar the region calendar, not null * @param stubType the stub type, not null * @param isExchangeNotional true if notional is to be exchanged * @param paymentLag the payment lag */ public FixedLegRollDateConvention( final String name, final ExternalIdBundle externalIdBundle, final Tenor paymentTenor, final DayCount dayCount, final Currency currency, final ExternalId regionCalendar, final StubType stubType, final boolean isExchangeNotional, final int paymentLag) { super(name, externalIdBundle); setPaymentTenor(paymentTenor); setDayCount(dayCount); setCurrency(currency); setRegionCalendar(regionCalendar); setStubType(stubType); setIsExchangeNotional(isExchangeNotional); setPaymentLag(paymentLag); } //------------------------------------------------------------------------- /** * Gets the type identifying this convention. * * @return the {@link #TYPE} constant, not null */ @Override public ConventionType getConventionType() { return TYPE; } /** * Accepts a visitor to manage traversal of the hierarchy. * * @param <T> the result type of the visitor * @param visitor the visitor, not null * @return the result */ @Override public <T> T accept(final FinancialConventionVisitor<T> visitor) { ArgumentChecker.notNull(visitor, "visitor"); return visitor.visitFixedLegRollDateConvention(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code FixedLegRollDateConvention}. * @return the meta-bean, not null */ public static FixedLegRollDateConvention.Meta meta() { return FixedLegRollDateConvention.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(FixedLegRollDateConvention.Meta.INSTANCE); } @Override public FixedLegRollDateConvention.Meta metaBean() { return FixedLegRollDateConvention.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the payment tenor. * @return the value of the property, not null */ public Tenor getPaymentTenor() { return _paymentTenor; } /** * Sets the payment tenor. * @param paymentTenor the new value of the property, not null */ public void setPaymentTenor(Tenor paymentTenor) { JodaBeanUtils.notNull(paymentTenor, "paymentTenor"); this._paymentTenor = paymentTenor; } /** * Gets the the {@code paymentTenor} property. * @return the property, not null */ public final Property<Tenor> paymentTenor() { return metaBean().paymentTenor().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the day count for the coupon payments. * @return the value of the property, not null */ public DayCount getDayCount() { return _dayCount; } /** * Sets the day count for the coupon payments. * @param dayCount the new value of the property, not null */ public void setDayCount(DayCount dayCount) { JodaBeanUtils.notNull(dayCount, "dayCount"); this._dayCount = dayCount; } /** * Gets the the {@code dayCount} property. * @return the property, not null */ public final Property<DayCount> dayCount() { return metaBean().dayCount().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the currency. * @return the value of the property, not null */ public Currency getCurrency() { return _currency; } /** * Sets the currency. * @param currency the new value of the property, not null */ public void setCurrency(Currency currency) { JodaBeanUtils.notNull(currency, "currency"); this._currency = currency; } /** * Gets the the {@code currency} property. * @return the property, not null */ public final Property<Currency> currency() { return metaBean().currency().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the region calendar. * @return the value of the property, not null */ public ExternalId getRegionCalendar() { return _regionCalendar; } /** * Sets the region calendar. * @param regionCalendar the new value of the property, not null */ public void setRegionCalendar(ExternalId regionCalendar) { JodaBeanUtils.notNull(regionCalendar, "regionCalendar"); this._regionCalendar = regionCalendar; } /** * Gets the the {@code regionCalendar} property. * @return the property, not null */ public final Property<ExternalId> regionCalendar() { return metaBean().regionCalendar().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the stub type. * @return the value of the property, not null */ public StubType getStubType() { return _stubType; } /** * Sets the stub type. * @param stubType the new value of the property, not null */ public void setStubType(StubType stubType) { JodaBeanUtils.notNull(stubType, "stubType"); this._stubType = stubType; } /** * Gets the the {@code stubType} property. * @return the property, not null */ public final Property<StubType> stubType() { return metaBean().stubType().createProperty(this); } //----------------------------------------------------------------------- /** * Gets whether the notional exchanged at the start and at the end. * @return the value of the property */ public boolean isIsExchangeNotional() { return _isExchangeNotional; } /** * Sets whether the notional exchanged at the start and at the end. * @param isExchangeNotional the new value of the property */ public void setIsExchangeNotional(boolean isExchangeNotional) { this._isExchangeNotional = isExchangeNotional; } /** * Gets the the {@code isExchangeNotional} property. * @return the property, not null */ public final Property<Boolean> isExchangeNotional() { return metaBean().isExchangeNotional().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the payment lag in days. * @return the value of the property */ public int getPaymentLag() { return _paymentLag; } /** * Sets the payment lag in days. * @param paymentLag the new value of the property */ public void setPaymentLag(int paymentLag) { this._paymentLag = paymentLag; } /** * Gets the the {@code paymentLag} property. * @return the property, not null */ public final Property<Integer> paymentLag() { return metaBean().paymentLag().createProperty(this); } //----------------------------------------------------------------------- @Override public FixedLegRollDateConvention clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { FixedLegRollDateConvention other = (FixedLegRollDateConvention) obj; return JodaBeanUtils.equal(getPaymentTenor(), other.getPaymentTenor()) && JodaBeanUtils.equal(getDayCount(), other.getDayCount()) && JodaBeanUtils.equal(getCurrency(), other.getCurrency()) && JodaBeanUtils.equal(getRegionCalendar(), other.getRegionCalendar()) && JodaBeanUtils.equal(getStubType(), other.getStubType()) && (isIsExchangeNotional() == other.isIsExchangeNotional()) && (getPaymentLag() == other.getPaymentLag()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getPaymentTenor()); hash = hash * 31 + JodaBeanUtils.hashCode(getDayCount()); hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getRegionCalendar()); hash = hash * 31 + JodaBeanUtils.hashCode(getStubType()); hash = hash * 31 + JodaBeanUtils.hashCode(isIsExchangeNotional()); hash = hash * 31 + JodaBeanUtils.hashCode(getPaymentLag()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(256); buf.append("FixedLegRollDateConvention{"); int len = buf.length(); toString(buf); if (buf.length() > len) { buf.setLength(buf.length() - 2); } buf.append('}'); return buf.toString(); } @Override protected void toString(StringBuilder buf) { super.toString(buf); buf.append("paymentTenor").append('=').append(JodaBeanUtils.toString(getPaymentTenor())).append(',').append(' '); buf.append("dayCount").append('=').append(JodaBeanUtils.toString(getDayCount())).append(',').append(' '); buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' '); buf.append("regionCalendar").append('=').append(JodaBeanUtils.toString(getRegionCalendar())).append(',').append(' '); buf.append("stubType").append('=').append(JodaBeanUtils.toString(getStubType())).append(',').append(' '); buf.append("isExchangeNotional").append('=').append(JodaBeanUtils.toString(isIsExchangeNotional())).append(',').append(' '); buf.append("paymentLag").append('=').append(JodaBeanUtils.toString(getPaymentLag())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code FixedLegRollDateConvention}. */ public static class Meta extends FinancialConvention.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code paymentTenor} property. */ private final MetaProperty<Tenor> _paymentTenor = DirectMetaProperty.ofReadWrite( this, "paymentTenor", FixedLegRollDateConvention.class, Tenor.class); /** * The meta-property for the {@code dayCount} property. */ private final MetaProperty<DayCount> _dayCount = DirectMetaProperty.ofReadWrite( this, "dayCount", FixedLegRollDateConvention.class, DayCount.class); /** * The meta-property for the {@code currency} property. */ private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite( this, "currency", FixedLegRollDateConvention.class, Currency.class); /** * The meta-property for the {@code regionCalendar} property. */ private final MetaProperty<ExternalId> _regionCalendar = DirectMetaProperty.ofReadWrite( this, "regionCalendar", FixedLegRollDateConvention.class, ExternalId.class); /** * The meta-property for the {@code stubType} property. */ private final MetaProperty<StubType> _stubType = DirectMetaProperty.ofReadWrite( this, "stubType", FixedLegRollDateConvention.class, StubType.class); /** * The meta-property for the {@code isExchangeNotional} property. */ private final MetaProperty<Boolean> _isExchangeNotional = DirectMetaProperty.ofReadWrite( this, "isExchangeNotional", FixedLegRollDateConvention.class, Boolean.TYPE); /** * The meta-property for the {@code paymentLag} property. */ private final MetaProperty<Integer> _paymentLag = DirectMetaProperty.ofReadWrite( this, "paymentLag", FixedLegRollDateConvention.class, Integer.TYPE); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "paymentTenor", "dayCount", "currency", "regionCalendar", "stubType", "isExchangeNotional", "paymentLag"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -507548582: // paymentTenor return _paymentTenor; case 1905311443: // dayCount return _dayCount; case 575402001: // currency return _currency; case 1932874322: // regionCalendar return _regionCalendar; case 1873675528: // stubType return _stubType; case 348962765: // isExchangeNotional return _isExchangeNotional; case 1612870060: // paymentLag return _paymentLag; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends FixedLegRollDateConvention> builder() { return new DirectBeanBuilder<FixedLegRollDateConvention>(new FixedLegRollDateConvention()); } @Override public Class<? extends FixedLegRollDateConvention> beanType() { return FixedLegRollDateConvention.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code paymentTenor} property. * @return the meta-property, not null */ public final MetaProperty<Tenor> paymentTenor() { return _paymentTenor; } /** * The meta-property for the {@code dayCount} property. * @return the meta-property, not null */ public final MetaProperty<DayCount> dayCount() { return _dayCount; } /** * The meta-property for the {@code currency} property. * @return the meta-property, not null */ public final MetaProperty<Currency> currency() { return _currency; } /** * The meta-property for the {@code regionCalendar} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> regionCalendar() { return _regionCalendar; } /** * The meta-property for the {@code stubType} property. * @return the meta-property, not null */ public final MetaProperty<StubType> stubType() { return _stubType; } /** * The meta-property for the {@code isExchangeNotional} property. * @return the meta-property, not null */ public final MetaProperty<Boolean> isExchangeNotional() { return _isExchangeNotional; } /** * The meta-property for the {@code paymentLag} property. * @return the meta-property, not null */ public final MetaProperty<Integer> paymentLag() { return _paymentLag; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -507548582: // paymentTenor return ((FixedLegRollDateConvention) bean).getPaymentTenor(); case 1905311443: // dayCount return ((FixedLegRollDateConvention) bean).getDayCount(); case 575402001: // currency return ((FixedLegRollDateConvention) bean).getCurrency(); case 1932874322: // regionCalendar return ((FixedLegRollDateConvention) bean).getRegionCalendar(); case 1873675528: // stubType return ((FixedLegRollDateConvention) bean).getStubType(); case 348962765: // isExchangeNotional return ((FixedLegRollDateConvention) bean).isIsExchangeNotional(); case 1612870060: // paymentLag return ((FixedLegRollDateConvention) bean).getPaymentLag(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -507548582: // paymentTenor ((FixedLegRollDateConvention) bean).setPaymentTenor((Tenor) newValue); return; case 1905311443: // dayCount ((FixedLegRollDateConvention) bean).setDayCount((DayCount) newValue); return; case 575402001: // currency ((FixedLegRollDateConvention) bean).setCurrency((Currency) newValue); return; case 1932874322: // regionCalendar ((FixedLegRollDateConvention) bean).setRegionCalendar((ExternalId) newValue); return; case 1873675528: // stubType ((FixedLegRollDateConvention) bean).setStubType((StubType) newValue); return; case 348962765: // isExchangeNotional ((FixedLegRollDateConvention) bean).setIsExchangeNotional((Boolean) newValue); return; case 1612870060: // paymentLag ((FixedLegRollDateConvention) bean).setPaymentLag((Integer) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((FixedLegRollDateConvention) bean)._paymentTenor, "paymentTenor"); JodaBeanUtils.notNull(((FixedLegRollDateConvention) bean)._dayCount, "dayCount"); JodaBeanUtils.notNull(((FixedLegRollDateConvention) bean)._currency, "currency"); JodaBeanUtils.notNull(((FixedLegRollDateConvention) bean)._regionCalendar, "regionCalendar"); JodaBeanUtils.notNull(((FixedLegRollDateConvention) bean)._stubType, "stubType"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }