/**
* Copyright (C) 2009 - 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;
/**
* The floating interest rate swap leg.
*/
@BeanDefinition
public class FloatingInterestRateLeg extends InterestRateLeg {
/** Serialization version. */
private static final long serialVersionUID = 1L;
/**
* The reference rate external identifier.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _floatingReferenceRateId;
/**
* The initial floating rate.
*/
@PropertyDefinition
private Double _initialFloatingRate;
/**
* The floating rate type.
*/
@PropertyDefinition(validate = "notNull")
private FloatingRateType _floatingRateType;
/**
* The settlement days
*/
@PropertyDefinition
private Integer _settlementDays;
/**
* The offset fixing frequency.
*/
@PropertyDefinition
private Frequency _offsetFixing;
/**
* Creates an instance.
*/
FloatingInterestRateLeg() { //For builder
}
/**
* Creates an instance.
*
* @param dayCount the day count, not null
* @param frequency the frequency, not null
* @param regionIdentifier the region, not null
* @param businessDayConvention the business day convention, not null
* @param notional the notional, not null
* @param eom whether this is EOM
* @param floatingReferenceRateId the reference rate, not null
* @param floatingRateType the floating rate type, not null
*/
public FloatingInterestRateLeg(DayCount dayCount, Frequency frequency, ExternalId regionIdentifier, BusinessDayConvention businessDayConvention,
Notional notional, boolean eom, ExternalId floatingReferenceRateId, FloatingRateType floatingRateType) {
super(dayCount, frequency, regionIdentifier, businessDayConvention, notional);
setFloatingReferenceRateId(floatingReferenceRateId);
setFloatingRateType(floatingRateType);
setEom(eom);
}
//-------------------------------------------------------------------------
@Override
public <T> T accept(SwapLegVisitor<T> visitor) {
return visitor.visitFloatingInterestRateLeg(this);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code FloatingInterestRateLeg}.
* @return the meta-bean, not null
*/
public static FloatingInterestRateLeg.Meta meta() {
return FloatingInterestRateLeg.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(FloatingInterestRateLeg.Meta.INSTANCE);
}
@Override
public FloatingInterestRateLeg.Meta metaBean() {
return FloatingInterestRateLeg.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the reference rate external identifier.
* @return the value of the property, not null
*/
public ExternalId getFloatingReferenceRateId() {
return _floatingReferenceRateId;
}
/**
* Sets the reference rate external identifier.
* @param floatingReferenceRateId the new value of the property, not null
*/
public void setFloatingReferenceRateId(ExternalId floatingReferenceRateId) {
JodaBeanUtils.notNull(floatingReferenceRateId, "floatingReferenceRateId");
this._floatingReferenceRateId = floatingReferenceRateId;
}
/**
* Gets the the {@code floatingReferenceRateId} property.
* @return the property, not null
*/
public final Property<ExternalId> floatingReferenceRateId() {
return metaBean().floatingReferenceRateId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the initial floating rate.
* @return the value of the property
*/
public Double getInitialFloatingRate() {
return _initialFloatingRate;
}
/**
* Sets the initial floating rate.
* @param initialFloatingRate the new value of the property
*/
public void setInitialFloatingRate(Double initialFloatingRate) {
this._initialFloatingRate = initialFloatingRate;
}
/**
* Gets the the {@code initialFloatingRate} property.
* @return the property, not null
*/
public final Property<Double> initialFloatingRate() {
return metaBean().initialFloatingRate().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the floating rate type.
* @return the value of the property, not null
*/
public FloatingRateType getFloatingRateType() {
return _floatingRateType;
}
/**
* Sets the floating rate type.
* @param floatingRateType the new value of the property, not null
*/
public void setFloatingRateType(FloatingRateType floatingRateType) {
JodaBeanUtils.notNull(floatingRateType, "floatingRateType");
this._floatingRateType = floatingRateType;
}
/**
* Gets the the {@code floatingRateType} property.
* @return the property, not null
*/
public final Property<FloatingRateType> floatingRateType() {
return metaBean().floatingRateType().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the settlement days
* @return the value of the property
*/
public Integer getSettlementDays() {
return _settlementDays;
}
/**
* Sets the settlement days
* @param settlementDays the new value of the property
*/
public void setSettlementDays(Integer settlementDays) {
this._settlementDays = settlementDays;
}
/**
* Gets the the {@code settlementDays} property.
* @return the property, not null
*/
public final Property<Integer> settlementDays() {
return metaBean().settlementDays().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the offset fixing frequency.
* @return the value of the property
*/
public Frequency getOffsetFixing() {
return _offsetFixing;
}
/**
* Sets the offset fixing frequency.
* @param offsetFixing the new value of the property
*/
public void setOffsetFixing(Frequency offsetFixing) {
this._offsetFixing = offsetFixing;
}
/**
* Gets the the {@code offsetFixing} property.
* @return the property, not null
*/
public final Property<Frequency> offsetFixing() {
return metaBean().offsetFixing().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public FloatingInterestRateLeg clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
FloatingInterestRateLeg other = (FloatingInterestRateLeg) obj;
return JodaBeanUtils.equal(getFloatingReferenceRateId(), other.getFloatingReferenceRateId()) &&
JodaBeanUtils.equal(getInitialFloatingRate(), other.getInitialFloatingRate()) &&
JodaBeanUtils.equal(getFloatingRateType(), other.getFloatingRateType()) &&
JodaBeanUtils.equal(getSettlementDays(), other.getSettlementDays()) &&
JodaBeanUtils.equal(getOffsetFixing(), other.getOffsetFixing()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getFloatingReferenceRateId());
hash = hash * 31 + JodaBeanUtils.hashCode(getInitialFloatingRate());
hash = hash * 31 + JodaBeanUtils.hashCode(getFloatingRateType());
hash = hash * 31 + JodaBeanUtils.hashCode(getSettlementDays());
hash = hash * 31 + JodaBeanUtils.hashCode(getOffsetFixing());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(192);
buf.append("FloatingInterestRateLeg{");
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("floatingReferenceRateId").append('=').append(JodaBeanUtils.toString(getFloatingReferenceRateId())).append(',').append(' ');
buf.append("initialFloatingRate").append('=').append(JodaBeanUtils.toString(getInitialFloatingRate())).append(',').append(' ');
buf.append("floatingRateType").append('=').append(JodaBeanUtils.toString(getFloatingRateType())).append(',').append(' ');
buf.append("settlementDays").append('=').append(JodaBeanUtils.toString(getSettlementDays())).append(',').append(' ');
buf.append("offsetFixing").append('=').append(JodaBeanUtils.toString(getOffsetFixing())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code FloatingInterestRateLeg}.
*/
public static class Meta extends InterestRateLeg.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code floatingReferenceRateId} property.
*/
private final MetaProperty<ExternalId> _floatingReferenceRateId = DirectMetaProperty.ofReadWrite(
this, "floatingReferenceRateId", FloatingInterestRateLeg.class, ExternalId.class);
/**
* The meta-property for the {@code initialFloatingRate} property.
*/
private final MetaProperty<Double> _initialFloatingRate = DirectMetaProperty.ofReadWrite(
this, "initialFloatingRate", FloatingInterestRateLeg.class, Double.class);
/**
* The meta-property for the {@code floatingRateType} property.
*/
private final MetaProperty<FloatingRateType> _floatingRateType = DirectMetaProperty.ofReadWrite(
this, "floatingRateType", FloatingInterestRateLeg.class, FloatingRateType.class);
/**
* The meta-property for the {@code settlementDays} property.
*/
private final MetaProperty<Integer> _settlementDays = DirectMetaProperty.ofReadWrite(
this, "settlementDays", FloatingInterestRateLeg.class, Integer.class);
/**
* The meta-property for the {@code offsetFixing} property.
*/
private final MetaProperty<Frequency> _offsetFixing = DirectMetaProperty.ofReadWrite(
this, "offsetFixing", FloatingInterestRateLeg.class, Frequency.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"floatingReferenceRateId",
"initialFloatingRate",
"floatingRateType",
"settlementDays",
"offsetFixing");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1120221088: // floatingReferenceRateId
return _floatingReferenceRateId;
case -1216922774: // initialFloatingRate
return _initialFloatingRate;
case 1642653280: // floatingRateType
return _floatingRateType;
case -295948000: // settlementDays
return _settlementDays;
case 180579872: // offsetFixing
return _offsetFixing;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends FloatingInterestRateLeg> builder() {
return new DirectBeanBuilder<FloatingInterestRateLeg>(new FloatingInterestRateLeg());
}
@Override
public Class<? extends FloatingInterestRateLeg> beanType() {
return FloatingInterestRateLeg.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code floatingReferenceRateId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> floatingReferenceRateId() {
return _floatingReferenceRateId;
}
/**
* The meta-property for the {@code initialFloatingRate} property.
* @return the meta-property, not null
*/
public final MetaProperty<Double> initialFloatingRate() {
return _initialFloatingRate;
}
/**
* The meta-property for the {@code floatingRateType} property.
* @return the meta-property, not null
*/
public final MetaProperty<FloatingRateType> floatingRateType() {
return _floatingRateType;
}
/**
* The meta-property for the {@code settlementDays} property.
* @return the meta-property, not null
*/
public final MetaProperty<Integer> settlementDays() {
return _settlementDays;
}
/**
* The meta-property for the {@code offsetFixing} property.
* @return the meta-property, not null
*/
public final MetaProperty<Frequency> offsetFixing() {
return _offsetFixing;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -1120221088: // floatingReferenceRateId
return ((FloatingInterestRateLeg) bean).getFloatingReferenceRateId();
case -1216922774: // initialFloatingRate
return ((FloatingInterestRateLeg) bean).getInitialFloatingRate();
case 1642653280: // floatingRateType
return ((FloatingInterestRateLeg) bean).getFloatingRateType();
case -295948000: // settlementDays
return ((FloatingInterestRateLeg) bean).getSettlementDays();
case 180579872: // offsetFixing
return ((FloatingInterestRateLeg) bean).getOffsetFixing();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -1120221088: // floatingReferenceRateId
((FloatingInterestRateLeg) bean).setFloatingReferenceRateId((ExternalId) newValue);
return;
case -1216922774: // initialFloatingRate
((FloatingInterestRateLeg) bean).setInitialFloatingRate((Double) newValue);
return;
case 1642653280: // floatingRateType
((FloatingInterestRateLeg) bean).setFloatingRateType((FloatingRateType) newValue);
return;
case -295948000: // settlementDays
((FloatingInterestRateLeg) bean).setSettlementDays((Integer) newValue);
return;
case 180579872: // offsetFixing
((FloatingInterestRateLeg) bean).setOffsetFixing((Frequency) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((FloatingInterestRateLeg) bean)._floatingReferenceRateId, "floatingReferenceRateId");
JodaBeanUtils.notNull(((FloatingInterestRateLeg) bean)._floatingRateType, "floatingRateType");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}