/** * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.security.swap; 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.financial.convention.businessday.BusinessDayConvention; import com.opengamma.financial.convention.daycount.DayCount; import com.opengamma.financial.convention.frequency.Frequency; import com.opengamma.id.ExternalId; import com.opengamma.util.ArgumentChecker; /** * An inflation swap leg linked to an index. */ @BeanDefinition public class InflationIndexSwapLeg extends InflationLeg { /** Serialization version */ private static final long serialVersionUID = 1L; /** * The external id of the index. */ @PropertyDefinition(validate = "notNull") private ExternalId _indexId; /** * The quotation indexation lag. */ @PropertyDefinition private int _quotationIndexationLag; /** * The conventional indexation lag. */ @PropertyDefinition private int _conventionalIndexationLag; /** * The interpolation method. */ @PropertyDefinition(validate = "notNull") private InterpolationMethod _interpolationMethod; /** * For the builder. */ /* package */InflationIndexSwapLeg() { super(); } /** * @param dayCount The day count, not null * @param frequency The frequency, not null * @param regionId The region id, not null * @param businessDayConvention The business day convention, not null * @param notional The notional, not null * @param isEOM True if dates follow the EOM convention * @param indexId The id of the index, not null * @param quotationIndexationLag The actual quotation indexation lag * @param conventionalIndexationLag The conventional indexation lag * @param interpolationMethod The interpolation method, not null */ public InflationIndexSwapLeg(final DayCount dayCount, final Frequency frequency, final ExternalId regionId, final BusinessDayConvention businessDayConvention, final Notional notional, final boolean isEOM, final ExternalId indexId, final int quotationIndexationLag, final int conventionalIndexationLag, final InterpolationMethod interpolationMethod) { super(dayCount, frequency, regionId, businessDayConvention, notional, isEOM); setIndexId(indexId); setQuotationIndexationLag(quotationIndexationLag); setConventionalIndexationLag(conventionalIndexationLag); setInterpolationMethod(interpolationMethod); } @Override public <T> T accept(final SwapLegVisitor<T> visitor) { ArgumentChecker.notNull(visitor, "visitor"); return visitor.visitInflationIndexSwapLeg(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code InflationIndexSwapLeg}. * @return the meta-bean, not null */ public static InflationIndexSwapLeg.Meta meta() { return InflationIndexSwapLeg.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(InflationIndexSwapLeg.Meta.INSTANCE); } @Override public InflationIndexSwapLeg.Meta metaBean() { return InflationIndexSwapLeg.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the external id of the index. * @return the value of the property, not null */ public ExternalId getIndexId() { return _indexId; } /** * Sets the external id of the index. * @param indexId the new value of the property, not null */ public void setIndexId(ExternalId indexId) { JodaBeanUtils.notNull(indexId, "indexId"); this._indexId = indexId; } /** * Gets the the {@code indexId} property. * @return the property, not null */ public final Property<ExternalId> indexId() { return metaBean().indexId().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the quotation indexation lag. * @return the value of the property */ public int getQuotationIndexationLag() { return _quotationIndexationLag; } /** * Sets the quotation indexation lag. * @param quotationIndexationLag the new value of the property */ public void setQuotationIndexationLag(int quotationIndexationLag) { this._quotationIndexationLag = quotationIndexationLag; } /** * Gets the the {@code quotationIndexationLag} property. * @return the property, not null */ public final Property<Integer> quotationIndexationLag() { return metaBean().quotationIndexationLag().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the conventional indexation lag. * @return the value of the property */ public int getConventionalIndexationLag() { return _conventionalIndexationLag; } /** * Sets the conventional indexation lag. * @param conventionalIndexationLag the new value of the property */ public void setConventionalIndexationLag(int conventionalIndexationLag) { this._conventionalIndexationLag = conventionalIndexationLag; } /** * Gets the the {@code conventionalIndexationLag} property. * @return the property, not null */ public final Property<Integer> conventionalIndexationLag() { return metaBean().conventionalIndexationLag().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the interpolation method. * @return the value of the property, not null */ public InterpolationMethod getInterpolationMethod() { return _interpolationMethod; } /** * Sets the interpolation method. * @param interpolationMethod the new value of the property, not null */ public void setInterpolationMethod(InterpolationMethod interpolationMethod) { JodaBeanUtils.notNull(interpolationMethod, "interpolationMethod"); this._interpolationMethod = interpolationMethod; } /** * Gets the the {@code interpolationMethod} property. * @return the property, not null */ public final Property<InterpolationMethod> interpolationMethod() { return metaBean().interpolationMethod().createProperty(this); } //----------------------------------------------------------------------- @Override public InflationIndexSwapLeg clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { InflationIndexSwapLeg other = (InflationIndexSwapLeg) obj; return JodaBeanUtils.equal(getIndexId(), other.getIndexId()) && (getQuotationIndexationLag() == other.getQuotationIndexationLag()) && (getConventionalIndexationLag() == other.getConventionalIndexationLag()) && JodaBeanUtils.equal(getInterpolationMethod(), other.getInterpolationMethod()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getIndexId()); hash = hash * 31 + JodaBeanUtils.hashCode(getQuotationIndexationLag()); hash = hash * 31 + JodaBeanUtils.hashCode(getConventionalIndexationLag()); hash = hash * 31 + JodaBeanUtils.hashCode(getInterpolationMethod()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("InflationIndexSwapLeg{"); 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("indexId").append('=').append(JodaBeanUtils.toString(getIndexId())).append(',').append(' '); buf.append("quotationIndexationLag").append('=').append(JodaBeanUtils.toString(getQuotationIndexationLag())).append(',').append(' '); buf.append("conventionalIndexationLag").append('=').append(JodaBeanUtils.toString(getConventionalIndexationLag())).append(',').append(' '); buf.append("interpolationMethod").append('=').append(JodaBeanUtils.toString(getInterpolationMethod())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code InflationIndexSwapLeg}. */ public static class Meta extends InflationLeg.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code indexId} property. */ private final MetaProperty<ExternalId> _indexId = DirectMetaProperty.ofReadWrite( this, "indexId", InflationIndexSwapLeg.class, ExternalId.class); /** * The meta-property for the {@code quotationIndexationLag} property. */ private final MetaProperty<Integer> _quotationIndexationLag = DirectMetaProperty.ofReadWrite( this, "quotationIndexationLag", InflationIndexSwapLeg.class, Integer.TYPE); /** * The meta-property for the {@code conventionalIndexationLag} property. */ private final MetaProperty<Integer> _conventionalIndexationLag = DirectMetaProperty.ofReadWrite( this, "conventionalIndexationLag", InflationIndexSwapLeg.class, Integer.TYPE); /** * The meta-property for the {@code interpolationMethod} property. */ private final MetaProperty<InterpolationMethod> _interpolationMethod = DirectMetaProperty.ofReadWrite( this, "interpolationMethod", InflationIndexSwapLeg.class, InterpolationMethod.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "indexId", "quotationIndexationLag", "conventionalIndexationLag", "interpolationMethod"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 1943291277: // indexId return _indexId; case -1106689277: // quotationIndexationLag return _quotationIndexationLag; case 1031469875: // conventionalIndexationLag return _conventionalIndexationLag; case 374385573: // interpolationMethod return _interpolationMethod; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends InflationIndexSwapLeg> builder() { return new DirectBeanBuilder<InflationIndexSwapLeg>(new InflationIndexSwapLeg()); } @Override public Class<? extends InflationIndexSwapLeg> beanType() { return InflationIndexSwapLeg.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code indexId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> indexId() { return _indexId; } /** * The meta-property for the {@code quotationIndexationLag} property. * @return the meta-property, not null */ public final MetaProperty<Integer> quotationIndexationLag() { return _quotationIndexationLag; } /** * The meta-property for the {@code conventionalIndexationLag} property. * @return the meta-property, not null */ public final MetaProperty<Integer> conventionalIndexationLag() { return _conventionalIndexationLag; } /** * The meta-property for the {@code interpolationMethod} property. * @return the meta-property, not null */ public final MetaProperty<InterpolationMethod> interpolationMethod() { return _interpolationMethod; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 1943291277: // indexId return ((InflationIndexSwapLeg) bean).getIndexId(); case -1106689277: // quotationIndexationLag return ((InflationIndexSwapLeg) bean).getQuotationIndexationLag(); case 1031469875: // conventionalIndexationLag return ((InflationIndexSwapLeg) bean).getConventionalIndexationLag(); case 374385573: // interpolationMethod return ((InflationIndexSwapLeg) bean).getInterpolationMethod(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 1943291277: // indexId ((InflationIndexSwapLeg) bean).setIndexId((ExternalId) newValue); return; case -1106689277: // quotationIndexationLag ((InflationIndexSwapLeg) bean).setQuotationIndexationLag((Integer) newValue); return; case 1031469875: // conventionalIndexationLag ((InflationIndexSwapLeg) bean).setConventionalIndexationLag((Integer) newValue); return; case 374385573: // interpolationMethod ((InflationIndexSwapLeg) bean).setInterpolationMethod((InterpolationMethod) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((InflationIndexSwapLeg) bean)._indexId, "indexId"); JodaBeanUtils.notNull(((InflationIndexSwapLeg) bean)._interpolationMethod, "interpolationMethod"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }