/**
* Copyright (C) 2014 - 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 org.threeten.bp.Period;
import com.opengamma.analytics.financial.credit.isdastandardmodel.CDSAnalyticFactory;
import com.opengamma.analytics.financial.credit.isdastandardmodel.StubType;
import com.opengamma.core.convention.ConventionType;
import com.opengamma.financial.convention.businessday.BusinessDayConvention;
import com.opengamma.financial.convention.daycount.DayCount;
import com.opengamma.id.ExternalId;
import com.opengamma.master.convention.ManageableConvention;
/**
* Fields defined here apply to CDSs created via the {@link CDSAnalyticFactory}.
* These apply to CDSs created for curve calibration.
*
* For a more detailed explanation on each of the fields listed here, see {@link CDSAnalyticFactory}.
*/
@BeanDefinition
public class IsdaCreditCurveConvention extends ManageableConvention {
private static final long serialVersionUID = 1L;
private static final ConventionType TYPE = ConventionType.of("ISDACreditCurve");
/**
* The step-in date, relative to T.
*/
@PropertyDefinition
private int _stepIn;
/**
* Cash settle date for which PV is calculated.
*/
@PropertyDefinition
private int _cashSettle;
/**
* Whether accrued premium is paid on default.
*/
@PropertyDefinition(validate = "notNull")
private boolean _payAccOnDefault;
/**
* The coupon interval.
*/
@PropertyDefinition(validate = "notNull")
private Period _couponInterval;
/**
* The stub type. See {@link StubType} for available values.
*/
@PropertyDefinition(validate = "notNull")
private StubType _stubType;
/**
* Protection starts at beginning of day if true, otherwise at the end.
*/
@PropertyDefinition
private boolean _protectFromStartOfDay;
/**
* Business day convention used for date rolling.
*/
@PropertyDefinition(validate = "notNull")
private BusinessDayConvention _businessDayConvention;
/**
* Defines the calendar to use.
* If null, weekend only calendar will be used.
*/
@PropertyDefinition
private ExternalId _regionId;
/**
* Day count for accrual calculations.
*/
@PropertyDefinition(validate = "notNull")
private DayCount _accrualDayCount;
/**
* Day count used for curve. (Note, values other than ACT/365 are not recommended. This is used by ISDA).
*/
@PropertyDefinition(validate = "notNull")
private DayCount _curveDayCount;
@Override
public ConventionType getConventionType() {
return TYPE;
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code IsdaCreditCurveConvention}.
* @return the meta-bean, not null
*/
public static IsdaCreditCurveConvention.Meta meta() {
return IsdaCreditCurveConvention.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(IsdaCreditCurveConvention.Meta.INSTANCE);
}
@Override
public IsdaCreditCurveConvention.Meta metaBean() {
return IsdaCreditCurveConvention.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the step-in date, relative to T.
* @return the value of the property
*/
public int getStepIn() {
return _stepIn;
}
/**
* Sets the step-in date, relative to T.
* @param stepIn the new value of the property
*/
public void setStepIn(int stepIn) {
this._stepIn = stepIn;
}
/**
* Gets the the {@code stepIn} property.
* @return the property, not null
*/
public final Property<Integer> stepIn() {
return metaBean().stepIn().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets cash settle date for which PV is calculated.
* @return the value of the property
*/
public int getCashSettle() {
return _cashSettle;
}
/**
* Sets cash settle date for which PV is calculated.
* @param cashSettle the new value of the property
*/
public void setCashSettle(int cashSettle) {
this._cashSettle = cashSettle;
}
/**
* Gets the the {@code cashSettle} property.
* @return the property, not null
*/
public final Property<Integer> cashSettle() {
return metaBean().cashSettle().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets whether accrued premium is paid on default.
* @return the value of the property, not null
*/
public boolean isPayAccOnDefault() {
return _payAccOnDefault;
}
/**
* Sets whether accrued premium is paid on default.
* @param payAccOnDefault the new value of the property, not null
*/
public void setPayAccOnDefault(boolean payAccOnDefault) {
JodaBeanUtils.notNull(payAccOnDefault, "payAccOnDefault");
this._payAccOnDefault = payAccOnDefault;
}
/**
* Gets the the {@code payAccOnDefault} property.
* @return the property, not null
*/
public final Property<Boolean> payAccOnDefault() {
return metaBean().payAccOnDefault().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the coupon interval.
* @return the value of the property, not null
*/
public Period getCouponInterval() {
return _couponInterval;
}
/**
* Sets the coupon interval.
* @param couponInterval the new value of the property, not null
*/
public void setCouponInterval(Period couponInterval) {
JodaBeanUtils.notNull(couponInterval, "couponInterval");
this._couponInterval = couponInterval;
}
/**
* Gets the the {@code couponInterval} property.
* @return the property, not null
*/
public final Property<Period> couponInterval() {
return metaBean().couponInterval().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the stub type. See {@link StubType} for available values.
* @return the value of the property, not null
*/
public StubType getStubType() {
return _stubType;
}
/**
* Sets the stub type. See {@link StubType} for available values.
* @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 protection starts at beginning of day if true, otherwise at the end.
* @return the value of the property
*/
public boolean isProtectFromStartOfDay() {
return _protectFromStartOfDay;
}
/**
* Sets protection starts at beginning of day if true, otherwise at the end.
* @param protectFromStartOfDay the new value of the property
*/
public void setProtectFromStartOfDay(boolean protectFromStartOfDay) {
this._protectFromStartOfDay = protectFromStartOfDay;
}
/**
* Gets the the {@code protectFromStartOfDay} property.
* @return the property, not null
*/
public final Property<Boolean> protectFromStartOfDay() {
return metaBean().protectFromStartOfDay().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets business day convention used for date rolling.
* @return the value of the property, not null
*/
public BusinessDayConvention getBusinessDayConvention() {
return _businessDayConvention;
}
/**
* Sets business day convention used for date rolling.
* @param businessDayConvention the new value of the property, not null
*/
public void setBusinessDayConvention(BusinessDayConvention businessDayConvention) {
JodaBeanUtils.notNull(businessDayConvention, "businessDayConvention");
this._businessDayConvention = businessDayConvention;
}
/**
* Gets the the {@code businessDayConvention} property.
* @return the property, not null
*/
public final Property<BusinessDayConvention> businessDayConvention() {
return metaBean().businessDayConvention().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets defines the calendar to use.
* If null, weekend only calendar will be used.
* @return the value of the property
*/
public ExternalId getRegionId() {
return _regionId;
}
/**
* Sets defines the calendar to use.
* If null, weekend only calendar will be used.
* @param regionId the new value of the property
*/
public void setRegionId(ExternalId regionId) {
this._regionId = regionId;
}
/**
* Gets the the {@code regionId} property.
* If null, weekend only calendar will be used.
* @return the property, not null
*/
public final Property<ExternalId> regionId() {
return metaBean().regionId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets day count for accrual calculations.
* @return the value of the property, not null
*/
public DayCount getAccrualDayCount() {
return _accrualDayCount;
}
/**
* Sets day count for accrual calculations.
* @param accrualDayCount the new value of the property, not null
*/
public void setAccrualDayCount(DayCount accrualDayCount) {
JodaBeanUtils.notNull(accrualDayCount, "accrualDayCount");
this._accrualDayCount = accrualDayCount;
}
/**
* Gets the the {@code accrualDayCount} property.
* @return the property, not null
*/
public final Property<DayCount> accrualDayCount() {
return metaBean().accrualDayCount().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets day count used for curve. (Note, values other than ACT/365 are not recommended. This is used by ISDA).
* @return the value of the property, not null
*/
public DayCount getCurveDayCount() {
return _curveDayCount;
}
/**
* Sets day count used for curve. (Note, values other than ACT/365 are not recommended. This is used by ISDA).
* @param curveDayCount the new value of the property, not null
*/
public void setCurveDayCount(DayCount curveDayCount) {
JodaBeanUtils.notNull(curveDayCount, "curveDayCount");
this._curveDayCount = curveDayCount;
}
/**
* Gets the the {@code curveDayCount} property.
* @return the property, not null
*/
public final Property<DayCount> curveDayCount() {
return metaBean().curveDayCount().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public IsdaCreditCurveConvention clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
IsdaCreditCurveConvention other = (IsdaCreditCurveConvention) obj;
return (getStepIn() == other.getStepIn()) &&
(getCashSettle() == other.getCashSettle()) &&
(isPayAccOnDefault() == other.isPayAccOnDefault()) &&
JodaBeanUtils.equal(getCouponInterval(), other.getCouponInterval()) &&
JodaBeanUtils.equal(getStubType(), other.getStubType()) &&
(isProtectFromStartOfDay() == other.isProtectFromStartOfDay()) &&
JodaBeanUtils.equal(getBusinessDayConvention(), other.getBusinessDayConvention()) &&
JodaBeanUtils.equal(getRegionId(), other.getRegionId()) &&
JodaBeanUtils.equal(getAccrualDayCount(), other.getAccrualDayCount()) &&
JodaBeanUtils.equal(getCurveDayCount(), other.getCurveDayCount()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getStepIn());
hash = hash * 31 + JodaBeanUtils.hashCode(getCashSettle());
hash = hash * 31 + JodaBeanUtils.hashCode(isPayAccOnDefault());
hash = hash * 31 + JodaBeanUtils.hashCode(getCouponInterval());
hash = hash * 31 + JodaBeanUtils.hashCode(getStubType());
hash = hash * 31 + JodaBeanUtils.hashCode(isProtectFromStartOfDay());
hash = hash * 31 + JodaBeanUtils.hashCode(getBusinessDayConvention());
hash = hash * 31 + JodaBeanUtils.hashCode(getRegionId());
hash = hash * 31 + JodaBeanUtils.hashCode(getAccrualDayCount());
hash = hash * 31 + JodaBeanUtils.hashCode(getCurveDayCount());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(352);
buf.append("IsdaCreditCurveConvention{");
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("stepIn").append('=').append(JodaBeanUtils.toString(getStepIn())).append(',').append(' ');
buf.append("cashSettle").append('=').append(JodaBeanUtils.toString(getCashSettle())).append(',').append(' ');
buf.append("payAccOnDefault").append('=').append(JodaBeanUtils.toString(isPayAccOnDefault())).append(',').append(' ');
buf.append("couponInterval").append('=').append(JodaBeanUtils.toString(getCouponInterval())).append(',').append(' ');
buf.append("stubType").append('=').append(JodaBeanUtils.toString(getStubType())).append(',').append(' ');
buf.append("protectFromStartOfDay").append('=').append(JodaBeanUtils.toString(isProtectFromStartOfDay())).append(',').append(' ');
buf.append("businessDayConvention").append('=').append(JodaBeanUtils.toString(getBusinessDayConvention())).append(',').append(' ');
buf.append("regionId").append('=').append(JodaBeanUtils.toString(getRegionId())).append(',').append(' ');
buf.append("accrualDayCount").append('=').append(JodaBeanUtils.toString(getAccrualDayCount())).append(',').append(' ');
buf.append("curveDayCount").append('=').append(JodaBeanUtils.toString(getCurveDayCount())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code IsdaCreditCurveConvention}.
*/
public static class Meta extends ManageableConvention.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code stepIn} property.
*/
private final MetaProperty<Integer> _stepIn = DirectMetaProperty.ofReadWrite(
this, "stepIn", IsdaCreditCurveConvention.class, Integer.TYPE);
/**
* The meta-property for the {@code cashSettle} property.
*/
private final MetaProperty<Integer> _cashSettle = DirectMetaProperty.ofReadWrite(
this, "cashSettle", IsdaCreditCurveConvention.class, Integer.TYPE);
/**
* The meta-property for the {@code payAccOnDefault} property.
*/
private final MetaProperty<Boolean> _payAccOnDefault = DirectMetaProperty.ofReadWrite(
this, "payAccOnDefault", IsdaCreditCurveConvention.class, Boolean.TYPE);
/**
* The meta-property for the {@code couponInterval} property.
*/
private final MetaProperty<Period> _couponInterval = DirectMetaProperty.ofReadWrite(
this, "couponInterval", IsdaCreditCurveConvention.class, Period.class);
/**
* The meta-property for the {@code stubType} property.
*/
private final MetaProperty<StubType> _stubType = DirectMetaProperty.ofReadWrite(
this, "stubType", IsdaCreditCurveConvention.class, StubType.class);
/**
* The meta-property for the {@code protectFromStartOfDay} property.
*/
private final MetaProperty<Boolean> _protectFromStartOfDay = DirectMetaProperty.ofReadWrite(
this, "protectFromStartOfDay", IsdaCreditCurveConvention.class, Boolean.TYPE);
/**
* The meta-property for the {@code businessDayConvention} property.
*/
private final MetaProperty<BusinessDayConvention> _businessDayConvention = DirectMetaProperty.ofReadWrite(
this, "businessDayConvention", IsdaCreditCurveConvention.class, BusinessDayConvention.class);
/**
* The meta-property for the {@code regionId} property.
*/
private final MetaProperty<ExternalId> _regionId = DirectMetaProperty.ofReadWrite(
this, "regionId", IsdaCreditCurveConvention.class, ExternalId.class);
/**
* The meta-property for the {@code accrualDayCount} property.
*/
private final MetaProperty<DayCount> _accrualDayCount = DirectMetaProperty.ofReadWrite(
this, "accrualDayCount", IsdaCreditCurveConvention.class, DayCount.class);
/**
* The meta-property for the {@code curveDayCount} property.
*/
private final MetaProperty<DayCount> _curveDayCount = DirectMetaProperty.ofReadWrite(
this, "curveDayCount", IsdaCreditCurveConvention.class, DayCount.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"stepIn",
"cashSettle",
"payAccOnDefault",
"couponInterval",
"stubType",
"protectFromStartOfDay",
"businessDayConvention",
"regionId",
"accrualDayCount",
"curveDayCount");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -892367599: // stepIn
return _stepIn;
case 1634469470: // cashSettle
return _cashSettle;
case -988493655: // payAccOnDefault
return _payAccOnDefault;
case 854432523: // couponInterval
return _couponInterval;
case 1873675528: // stubType
return _stubType;
case 2052802300: // protectFromStartOfDay
return _protectFromStartOfDay;
case -1002835891: // businessDayConvention
return _businessDayConvention;
case -690339025: // regionId
return _regionId;
case -1387075166: // accrualDayCount
return _accrualDayCount;
case -1661418270: // curveDayCount
return _curveDayCount;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends IsdaCreditCurveConvention> builder() {
return new DirectBeanBuilder<IsdaCreditCurveConvention>(new IsdaCreditCurveConvention());
}
@Override
public Class<? extends IsdaCreditCurveConvention> beanType() {
return IsdaCreditCurveConvention.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code stepIn} property.
* @return the meta-property, not null
*/
public final MetaProperty<Integer> stepIn() {
return _stepIn;
}
/**
* The meta-property for the {@code cashSettle} property.
* @return the meta-property, not null
*/
public final MetaProperty<Integer> cashSettle() {
return _cashSettle;
}
/**
* The meta-property for the {@code payAccOnDefault} property.
* @return the meta-property, not null
*/
public final MetaProperty<Boolean> payAccOnDefault() {
return _payAccOnDefault;
}
/**
* The meta-property for the {@code couponInterval} property.
* @return the meta-property, not null
*/
public final MetaProperty<Period> couponInterval() {
return _couponInterval;
}
/**
* 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 protectFromStartOfDay} property.
* @return the meta-property, not null
*/
public final MetaProperty<Boolean> protectFromStartOfDay() {
return _protectFromStartOfDay;
}
/**
* The meta-property for the {@code businessDayConvention} property.
* @return the meta-property, not null
*/
public final MetaProperty<BusinessDayConvention> businessDayConvention() {
return _businessDayConvention;
}
/**
* The meta-property for the {@code regionId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> regionId() {
return _regionId;
}
/**
* The meta-property for the {@code accrualDayCount} property.
* @return the meta-property, not null
*/
public final MetaProperty<DayCount> accrualDayCount() {
return _accrualDayCount;
}
/**
* The meta-property for the {@code curveDayCount} property.
* @return the meta-property, not null
*/
public final MetaProperty<DayCount> curveDayCount() {
return _curveDayCount;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -892367599: // stepIn
return ((IsdaCreditCurveConvention) bean).getStepIn();
case 1634469470: // cashSettle
return ((IsdaCreditCurveConvention) bean).getCashSettle();
case -988493655: // payAccOnDefault
return ((IsdaCreditCurveConvention) bean).isPayAccOnDefault();
case 854432523: // couponInterval
return ((IsdaCreditCurveConvention) bean).getCouponInterval();
case 1873675528: // stubType
return ((IsdaCreditCurveConvention) bean).getStubType();
case 2052802300: // protectFromStartOfDay
return ((IsdaCreditCurveConvention) bean).isProtectFromStartOfDay();
case -1002835891: // businessDayConvention
return ((IsdaCreditCurveConvention) bean).getBusinessDayConvention();
case -690339025: // regionId
return ((IsdaCreditCurveConvention) bean).getRegionId();
case -1387075166: // accrualDayCount
return ((IsdaCreditCurveConvention) bean).getAccrualDayCount();
case -1661418270: // curveDayCount
return ((IsdaCreditCurveConvention) bean).getCurveDayCount();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -892367599: // stepIn
((IsdaCreditCurveConvention) bean).setStepIn((Integer) newValue);
return;
case 1634469470: // cashSettle
((IsdaCreditCurveConvention) bean).setCashSettle((Integer) newValue);
return;
case -988493655: // payAccOnDefault
((IsdaCreditCurveConvention) bean).setPayAccOnDefault((Boolean) newValue);
return;
case 854432523: // couponInterval
((IsdaCreditCurveConvention) bean).setCouponInterval((Period) newValue);
return;
case 1873675528: // stubType
((IsdaCreditCurveConvention) bean).setStubType((StubType) newValue);
return;
case 2052802300: // protectFromStartOfDay
((IsdaCreditCurveConvention) bean).setProtectFromStartOfDay((Boolean) newValue);
return;
case -1002835891: // businessDayConvention
((IsdaCreditCurveConvention) bean).setBusinessDayConvention((BusinessDayConvention) newValue);
return;
case -690339025: // regionId
((IsdaCreditCurveConvention) bean).setRegionId((ExternalId) newValue);
return;
case -1387075166: // accrualDayCount
((IsdaCreditCurveConvention) bean).setAccrualDayCount((DayCount) newValue);
return;
case -1661418270: // curveDayCount
((IsdaCreditCurveConvention) bean).setCurveDayCount((DayCount) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((IsdaCreditCurveConvention) bean)._payAccOnDefault, "payAccOnDefault");
JodaBeanUtils.notNull(((IsdaCreditCurveConvention) bean)._couponInterval, "couponInterval");
JodaBeanUtils.notNull(((IsdaCreditCurveConvention) bean)._stubType, "stubType");
JodaBeanUtils.notNull(((IsdaCreditCurveConvention) bean)._businessDayConvention, "businessDayConvention");
JodaBeanUtils.notNull(((IsdaCreditCurveConvention) bean)._accrualDayCount, "accrualDayCount");
JodaBeanUtils.notNull(((IsdaCreditCurveConvention) bean)._curveDayCount, "curveDayCount");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}