/** * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.analytics.ircurve.strips; 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.id.ExternalId; import com.opengamma.util.ArgumentChecker; import com.opengamma.util.time.Tenor; /** * An IMM FRA curve node. */ @BeanDefinition public class RollDateFRANode extends CurveNode { /** Serialization version */ private static final long serialVersionUID = 1L; /** * The start tenor. */ @PropertyDefinition(validate = "notNull") private Tenor _startTenor; /** * The index tenor. */ @PropertyDefinition(validate = "notNull") private Tenor _indexTenor; /** * The roll date start number. */ @PropertyDefinition(validate = "notNull") private int _rollDateStartNumber; /** * The roll date end number. */ @PropertyDefinition(validate = "notNull") private int _rollDateEndNumber; /** * The IMM FRA convention with the underlying convention and the roll date convention. */ @PropertyDefinition(validate = "notNull") private ExternalId _rollDateFRAConvention; /** * For the builder. */ RollDateFRANode() { super(); } /** * Sets the useFixings field to true and the node name to null * @param startTenor The start tenor, not null * @param indexTenor The index tenor, not null * @param rollDateStartNumber The IMM date start number, not negative or zero * @param rollDateEndNumber The IMM date end number, not negative or zero * @param convention The swap convention, not null * @param curveNodeIdMapperName The curve node id mapper name, not null */ public RollDateFRANode(final Tenor startTenor, final Tenor indexTenor, final int rollDateStartNumber, final int rollDateEndNumber, final ExternalId convention, final String curveNodeIdMapperName) { super(curveNodeIdMapperName); setStartTenor(startTenor); setIndexTenor(indexTenor); setRollDateStartNumber(rollDateStartNumber); setRollDateEndNumber(rollDateEndNumber); setRollDateFRAConvention(convention); } /** * Sets the useFixings field to true and the node name to null * @param startTenor The start tenor, not null * @param indexTenor The index tenor, not null * @param rollDateStartNumber The IMM date start number, not negative or zero * @param rollDateEndNumber The IMM date end number, not negative or zero * @param convention The IMM FRA convention, not null * @param curveNodeIdMapperName The curve node id mapper name, not null * @param name The curve node name */ public RollDateFRANode(final Tenor startTenor, final Tenor indexTenor, final int rollDateStartNumber, final int rollDateEndNumber, final ExternalId convention, final String curveNodeIdMapperName, final String name) { super(curveNodeIdMapperName, name); setStartTenor(startTenor); setIndexTenor(indexTenor); setRollDateStartNumber(rollDateStartNumber); setRollDateEndNumber(rollDateEndNumber); setRollDateFRAConvention(convention); } @Override public Tenor getResolvedMaturity() { final int m = getIndexTenor().getPeriod().getMonths(); // TODO: Review: should it be index tenor or Roll date adjuster period? return Tenor.of(getStartTenor().getPeriod().plusMonths(m * getRollDateEndNumber())); } @Override public <T> T accept(final CurveNodeVisitor<T> visitor) { ArgumentChecker.notNull(visitor, "visitor"); return visitor.visitRollDateFRANode(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code RollDateFRANode}. * @return the meta-bean, not null */ public static RollDateFRANode.Meta meta() { return RollDateFRANode.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(RollDateFRANode.Meta.INSTANCE); } @Override public RollDateFRANode.Meta metaBean() { return RollDateFRANode.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the start tenor. * @return the value of the property, not null */ public Tenor getStartTenor() { return _startTenor; } /** * Sets the start tenor. * @param startTenor the new value of the property, not null */ public void setStartTenor(Tenor startTenor) { JodaBeanUtils.notNull(startTenor, "startTenor"); this._startTenor = startTenor; } /** * Gets the the {@code startTenor} property. * @return the property, not null */ public final Property<Tenor> startTenor() { return metaBean().startTenor().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the index tenor. * @return the value of the property, not null */ public Tenor getIndexTenor() { return _indexTenor; } /** * Sets the index tenor. * @param indexTenor the new value of the property, not null */ public void setIndexTenor(Tenor indexTenor) { JodaBeanUtils.notNull(indexTenor, "indexTenor"); this._indexTenor = indexTenor; } /** * Gets the the {@code indexTenor} property. * @return the property, not null */ public final Property<Tenor> indexTenor() { return metaBean().indexTenor().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the roll date start number. * @return the value of the property, not null */ public int getRollDateStartNumber() { return _rollDateStartNumber; } /** * Sets the roll date start number. * @param rollDateStartNumber the new value of the property, not null */ public void setRollDateStartNumber(int rollDateStartNumber) { JodaBeanUtils.notNull(rollDateStartNumber, "rollDateStartNumber"); this._rollDateStartNumber = rollDateStartNumber; } /** * Gets the the {@code rollDateStartNumber} property. * @return the property, not null */ public final Property<Integer> rollDateStartNumber() { return metaBean().rollDateStartNumber().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the roll date end number. * @return the value of the property, not null */ public int getRollDateEndNumber() { return _rollDateEndNumber; } /** * Sets the roll date end number. * @param rollDateEndNumber the new value of the property, not null */ public void setRollDateEndNumber(int rollDateEndNumber) { JodaBeanUtils.notNull(rollDateEndNumber, "rollDateEndNumber"); this._rollDateEndNumber = rollDateEndNumber; } /** * Gets the the {@code rollDateEndNumber} property. * @return the property, not null */ public final Property<Integer> rollDateEndNumber() { return metaBean().rollDateEndNumber().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the IMM FRA convention with the underlying convention and the roll date convention. * @return the value of the property, not null */ public ExternalId getRollDateFRAConvention() { return _rollDateFRAConvention; } /** * Sets the IMM FRA convention with the underlying convention and the roll date convention. * @param rollDateFRAConvention the new value of the property, not null */ public void setRollDateFRAConvention(ExternalId rollDateFRAConvention) { JodaBeanUtils.notNull(rollDateFRAConvention, "rollDateFRAConvention"); this._rollDateFRAConvention = rollDateFRAConvention; } /** * Gets the the {@code rollDateFRAConvention} property. * @return the property, not null */ public final Property<ExternalId> rollDateFRAConvention() { return metaBean().rollDateFRAConvention().createProperty(this); } //----------------------------------------------------------------------- @Override public RollDateFRANode clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { RollDateFRANode other = (RollDateFRANode) obj; return JodaBeanUtils.equal(getStartTenor(), other.getStartTenor()) && JodaBeanUtils.equal(getIndexTenor(), other.getIndexTenor()) && (getRollDateStartNumber() == other.getRollDateStartNumber()) && (getRollDateEndNumber() == other.getRollDateEndNumber()) && JodaBeanUtils.equal(getRollDateFRAConvention(), other.getRollDateFRAConvention()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getStartTenor()); hash = hash * 31 + JodaBeanUtils.hashCode(getIndexTenor()); hash = hash * 31 + JodaBeanUtils.hashCode(getRollDateStartNumber()); hash = hash * 31 + JodaBeanUtils.hashCode(getRollDateEndNumber()); hash = hash * 31 + JodaBeanUtils.hashCode(getRollDateFRAConvention()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(192); buf.append("RollDateFRANode{"); 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("startTenor").append('=').append(JodaBeanUtils.toString(getStartTenor())).append(',').append(' '); buf.append("indexTenor").append('=').append(JodaBeanUtils.toString(getIndexTenor())).append(',').append(' '); buf.append("rollDateStartNumber").append('=').append(JodaBeanUtils.toString(getRollDateStartNumber())).append(',').append(' '); buf.append("rollDateEndNumber").append('=').append(JodaBeanUtils.toString(getRollDateEndNumber())).append(',').append(' '); buf.append("rollDateFRAConvention").append('=').append(JodaBeanUtils.toString(getRollDateFRAConvention())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code RollDateFRANode}. */ public static class Meta extends CurveNode.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code startTenor} property. */ private final MetaProperty<Tenor> _startTenor = DirectMetaProperty.ofReadWrite( this, "startTenor", RollDateFRANode.class, Tenor.class); /** * The meta-property for the {@code indexTenor} property. */ private final MetaProperty<Tenor> _indexTenor = DirectMetaProperty.ofReadWrite( this, "indexTenor", RollDateFRANode.class, Tenor.class); /** * The meta-property for the {@code rollDateStartNumber} property. */ private final MetaProperty<Integer> _rollDateStartNumber = DirectMetaProperty.ofReadWrite( this, "rollDateStartNumber", RollDateFRANode.class, Integer.TYPE); /** * The meta-property for the {@code rollDateEndNumber} property. */ private final MetaProperty<Integer> _rollDateEndNumber = DirectMetaProperty.ofReadWrite( this, "rollDateEndNumber", RollDateFRANode.class, Integer.TYPE); /** * The meta-property for the {@code rollDateFRAConvention} property. */ private final MetaProperty<ExternalId> _rollDateFRAConvention = DirectMetaProperty.ofReadWrite( this, "rollDateFRAConvention", RollDateFRANode.class, ExternalId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "startTenor", "indexTenor", "rollDateStartNumber", "rollDateEndNumber", "rollDateFRAConvention"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -1583746178: // startTenor return _startTenor; case 736548110: // indexTenor return _indexTenor; case 2110556032: // rollDateStartNumber return _rollDateStartNumber; case -660728199: // rollDateEndNumber return _rollDateEndNumber; case -483000741: // rollDateFRAConvention return _rollDateFRAConvention; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends RollDateFRANode> builder() { return new DirectBeanBuilder<RollDateFRANode>(new RollDateFRANode()); } @Override public Class<? extends RollDateFRANode> beanType() { return RollDateFRANode.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code startTenor} property. * @return the meta-property, not null */ public final MetaProperty<Tenor> startTenor() { return _startTenor; } /** * The meta-property for the {@code indexTenor} property. * @return the meta-property, not null */ public final MetaProperty<Tenor> indexTenor() { return _indexTenor; } /** * The meta-property for the {@code rollDateStartNumber} property. * @return the meta-property, not null */ public final MetaProperty<Integer> rollDateStartNumber() { return _rollDateStartNumber; } /** * The meta-property for the {@code rollDateEndNumber} property. * @return the meta-property, not null */ public final MetaProperty<Integer> rollDateEndNumber() { return _rollDateEndNumber; } /** * The meta-property for the {@code rollDateFRAConvention} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> rollDateFRAConvention() { return _rollDateFRAConvention; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -1583746178: // startTenor return ((RollDateFRANode) bean).getStartTenor(); case 736548110: // indexTenor return ((RollDateFRANode) bean).getIndexTenor(); case 2110556032: // rollDateStartNumber return ((RollDateFRANode) bean).getRollDateStartNumber(); case -660728199: // rollDateEndNumber return ((RollDateFRANode) bean).getRollDateEndNumber(); case -483000741: // rollDateFRAConvention return ((RollDateFRANode) bean).getRollDateFRAConvention(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -1583746178: // startTenor ((RollDateFRANode) bean).setStartTenor((Tenor) newValue); return; case 736548110: // indexTenor ((RollDateFRANode) bean).setIndexTenor((Tenor) newValue); return; case 2110556032: // rollDateStartNumber ((RollDateFRANode) bean).setRollDateStartNumber((Integer) newValue); return; case -660728199: // rollDateEndNumber ((RollDateFRANode) bean).setRollDateEndNumber((Integer) newValue); return; case -483000741: // rollDateFRAConvention ((RollDateFRANode) bean).setRollDateFRAConvention((ExternalId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((RollDateFRANode) bean)._startTenor, "startTenor"); JodaBeanUtils.notNull(((RollDateFRANode) bean)._indexTenor, "indexTenor"); JodaBeanUtils.notNull(((RollDateFRANode) bean)._rollDateStartNumber, "rollDateStartNumber"); JodaBeanUtils.notNull(((RollDateFRANode) bean)._rollDateEndNumber, "rollDateEndNumber"); JodaBeanUtils.notNull(((RollDateFRANode) bean)._rollDateFRAConvention, "rollDateFRAConvention"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }