/** * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.security.option; 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.ZonedDateTime; import com.opengamma.financial.security.FinancialSecurity; import com.opengamma.financial.security.FinancialSecurityVisitor; import com.opengamma.id.ExternalId; import com.opengamma.master.security.SecurityDescription; import com.opengamma.util.money.Currency; /** * */ @BeanDefinition @SecurityDescription(type = CreditDefaultSwapOptionSecurity.SECURITY_TYPE, description = "Credit default swap option") public class CreditDefaultSwapOptionSecurity extends FinancialSecurity { /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The security type. */ public static final String SECURITY_TYPE = "CREDIT_DEFAULT_SWAP_OPTION"; /** * Has the protection been bought. If false, protection has been sold. */ @PropertyDefinition private boolean _buy; /** * The protection buyer. */ @PropertyDefinition(validate = "notNull") private ExternalId _protectionBuyer; /** * The protection seller. */ @PropertyDefinition(validate = "notNull") private ExternalId _protectionSeller; /** * The start date. */ @PropertyDefinition(validate = "notNull") private ZonedDateTime _startDate; /** * The maturity date. */ @PropertyDefinition(validate = "notNull") private ZonedDateTime _maturityDate; /** * The currency. */ @PropertyDefinition(validate = "notNull") private Currency _currency; /** * The notional. */ @PropertyDefinition(validate = "notNull") private Double _notional; /** * The strike. */ @PropertyDefinition(validate = "notNull") private Double _strike; /** * The knock-out type. */ @PropertyDefinition private boolean _knockOut; /** * The option type, true if the option is a payer. */ @PropertyDefinition private boolean _payer; /** * The exercise type. */ @PropertyDefinition(validate = "notNull") private ExerciseType _exerciseType; /** * The underlying CDS. */ @PropertyDefinition(validate = "notNull") private ExternalId _underlyingId; /** * Constructor used by Fudge */ CreditDefaultSwapOptionSecurity() { super(SECURITY_TYPE); } public CreditDefaultSwapOptionSecurity(final boolean buy, final ExternalId protectionBuyer, final ExternalId protectionSeller, final ZonedDateTime startDate, final ZonedDateTime maturityDate, final Currency currency, final Double notional, final Double strike, final boolean isKnockOut, final boolean payer, final ExerciseType exerciseType, final ExternalId underlyingId) { super(SECURITY_TYPE); setBuy(buy); setProtectionBuyer(protectionBuyer); setProtectionSeller(protectionSeller); setStartDate(startDate); setMaturityDate(maturityDate); setCurrency(currency); setNotional(notional); setStrike(strike); setKnockOut(isKnockOut); setPayer(payer); setExerciseType(exerciseType); setUnderlyingId(underlyingId); } @Override public <T> T accept(final FinancialSecurityVisitor<T> visitor) { return visitor.visitCreditDefaultSwapOptionSecurity(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code CreditDefaultSwapOptionSecurity}. * @return the meta-bean, not null */ public static CreditDefaultSwapOptionSecurity.Meta meta() { return CreditDefaultSwapOptionSecurity.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(CreditDefaultSwapOptionSecurity.Meta.INSTANCE); } @Override public CreditDefaultSwapOptionSecurity.Meta metaBean() { return CreditDefaultSwapOptionSecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets has the protection been bought. If false, protection has been sold. * @return the value of the property */ public boolean isBuy() { return _buy; } /** * Sets has the protection been bought. If false, protection has been sold. * @param buy the new value of the property */ public void setBuy(boolean buy) { this._buy = buy; } /** * Gets the the {@code buy} property. * @return the property, not null */ public final Property<Boolean> buy() { return metaBean().buy().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the protection buyer. * @return the value of the property, not null */ public ExternalId getProtectionBuyer() { return _protectionBuyer; } /** * Sets the protection buyer. * @param protectionBuyer the new value of the property, not null */ public void setProtectionBuyer(ExternalId protectionBuyer) { JodaBeanUtils.notNull(protectionBuyer, "protectionBuyer"); this._protectionBuyer = protectionBuyer; } /** * Gets the the {@code protectionBuyer} property. * @return the property, not null */ public final Property<ExternalId> protectionBuyer() { return metaBean().protectionBuyer().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the protection seller. * @return the value of the property, not null */ public ExternalId getProtectionSeller() { return _protectionSeller; } /** * Sets the protection seller. * @param protectionSeller the new value of the property, not null */ public void setProtectionSeller(ExternalId protectionSeller) { JodaBeanUtils.notNull(protectionSeller, "protectionSeller"); this._protectionSeller = protectionSeller; } /** * Gets the the {@code protectionSeller} property. * @return the property, not null */ public final Property<ExternalId> protectionSeller() { return metaBean().protectionSeller().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the start date. * @return the value of the property, not null */ public ZonedDateTime getStartDate() { return _startDate; } /** * Sets the start date. * @param startDate the new value of the property, not null */ public void setStartDate(ZonedDateTime startDate) { JodaBeanUtils.notNull(startDate, "startDate"); this._startDate = startDate; } /** * Gets the the {@code startDate} property. * @return the property, not null */ public final Property<ZonedDateTime> startDate() { return metaBean().startDate().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the maturity date. * @return the value of the property, not null */ public ZonedDateTime getMaturityDate() { return _maturityDate; } /** * Sets the maturity date. * @param maturityDate the new value of the property, not null */ public void setMaturityDate(ZonedDateTime maturityDate) { JodaBeanUtils.notNull(maturityDate, "maturityDate"); this._maturityDate = maturityDate; } /** * Gets the the {@code maturityDate} property. * @return the property, not null */ public final Property<ZonedDateTime> maturityDate() { return metaBean().maturityDate().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 notional. * @return the value of the property, not null */ public Double getNotional() { return _notional; } /** * Sets the notional. * @param notional the new value of the property, not null */ public void setNotional(Double notional) { JodaBeanUtils.notNull(notional, "notional"); this._notional = notional; } /** * Gets the the {@code notional} property. * @return the property, not null */ public final Property<Double> notional() { return metaBean().notional().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the strike. * @return the value of the property, not null */ public Double getStrike() { return _strike; } /** * Sets the strike. * @param strike the new value of the property, not null */ public void setStrike(Double strike) { JodaBeanUtils.notNull(strike, "strike"); this._strike = strike; } /** * Gets the the {@code strike} property. * @return the property, not null */ public final Property<Double> strike() { return metaBean().strike().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the knock-out type. * @return the value of the property */ public boolean isKnockOut() { return _knockOut; } /** * Sets the knock-out type. * @param knockOut the new value of the property */ public void setKnockOut(boolean knockOut) { this._knockOut = knockOut; } /** * Gets the the {@code knockOut} property. * @return the property, not null */ public final Property<Boolean> knockOut() { return metaBean().knockOut().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the option type, true if the option is a payer. * @return the value of the property */ public boolean isPayer() { return _payer; } /** * Sets the option type, true if the option is a payer. * @param payer the new value of the property */ public void setPayer(boolean payer) { this._payer = payer; } /** * Gets the the {@code payer} property. * @return the property, not null */ public final Property<Boolean> payer() { return metaBean().payer().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the exercise type. * @return the value of the property, not null */ public ExerciseType getExerciseType() { return _exerciseType; } /** * Sets the exercise type. * @param exerciseType the new value of the property, not null */ public void setExerciseType(ExerciseType exerciseType) { JodaBeanUtils.notNull(exerciseType, "exerciseType"); this._exerciseType = exerciseType; } /** * Gets the the {@code exerciseType} property. * @return the property, not null */ public final Property<ExerciseType> exerciseType() { return metaBean().exerciseType().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the underlying CDS. * @return the value of the property, not null */ public ExternalId getUnderlyingId() { return _underlyingId; } /** * Sets the underlying CDS. * @param underlyingId the new value of the property, not null */ public void setUnderlyingId(ExternalId underlyingId) { JodaBeanUtils.notNull(underlyingId, "underlyingId"); this._underlyingId = underlyingId; } /** * Gets the the {@code underlyingId} property. * @return the property, not null */ public final Property<ExternalId> underlyingId() { return metaBean().underlyingId().createProperty(this); } //----------------------------------------------------------------------- @Override public CreditDefaultSwapOptionSecurity clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { CreditDefaultSwapOptionSecurity other = (CreditDefaultSwapOptionSecurity) obj; return (isBuy() == other.isBuy()) && JodaBeanUtils.equal(getProtectionBuyer(), other.getProtectionBuyer()) && JodaBeanUtils.equal(getProtectionSeller(), other.getProtectionSeller()) && JodaBeanUtils.equal(getStartDate(), other.getStartDate()) && JodaBeanUtils.equal(getMaturityDate(), other.getMaturityDate()) && JodaBeanUtils.equal(getCurrency(), other.getCurrency()) && JodaBeanUtils.equal(getNotional(), other.getNotional()) && JodaBeanUtils.equal(getStrike(), other.getStrike()) && (isKnockOut() == other.isKnockOut()) && (isPayer() == other.isPayer()) && JodaBeanUtils.equal(getExerciseType(), other.getExerciseType()) && JodaBeanUtils.equal(getUnderlyingId(), other.getUnderlyingId()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(isBuy()); hash = hash * 31 + JodaBeanUtils.hashCode(getProtectionBuyer()); hash = hash * 31 + JodaBeanUtils.hashCode(getProtectionSeller()); hash = hash * 31 + JodaBeanUtils.hashCode(getStartDate()); hash = hash * 31 + JodaBeanUtils.hashCode(getMaturityDate()); hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getNotional()); hash = hash * 31 + JodaBeanUtils.hashCode(getStrike()); hash = hash * 31 + JodaBeanUtils.hashCode(isKnockOut()); hash = hash * 31 + JodaBeanUtils.hashCode(isPayer()); hash = hash * 31 + JodaBeanUtils.hashCode(getExerciseType()); hash = hash * 31 + JodaBeanUtils.hashCode(getUnderlyingId()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(416); buf.append("CreditDefaultSwapOptionSecurity{"); 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("buy").append('=').append(JodaBeanUtils.toString(isBuy())).append(',').append(' '); buf.append("protectionBuyer").append('=').append(JodaBeanUtils.toString(getProtectionBuyer())).append(',').append(' '); buf.append("protectionSeller").append('=').append(JodaBeanUtils.toString(getProtectionSeller())).append(',').append(' '); buf.append("startDate").append('=').append(JodaBeanUtils.toString(getStartDate())).append(',').append(' '); buf.append("maturityDate").append('=').append(JodaBeanUtils.toString(getMaturityDate())).append(',').append(' '); buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' '); buf.append("notional").append('=').append(JodaBeanUtils.toString(getNotional())).append(',').append(' '); buf.append("strike").append('=').append(JodaBeanUtils.toString(getStrike())).append(',').append(' '); buf.append("knockOut").append('=').append(JodaBeanUtils.toString(isKnockOut())).append(',').append(' '); buf.append("payer").append('=').append(JodaBeanUtils.toString(isPayer())).append(',').append(' '); buf.append("exerciseType").append('=').append(JodaBeanUtils.toString(getExerciseType())).append(',').append(' '); buf.append("underlyingId").append('=').append(JodaBeanUtils.toString(getUnderlyingId())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code CreditDefaultSwapOptionSecurity}. */ public static class Meta extends FinancialSecurity.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code buy} property. */ private final MetaProperty<Boolean> _buy = DirectMetaProperty.ofReadWrite( this, "buy", CreditDefaultSwapOptionSecurity.class, Boolean.TYPE); /** * The meta-property for the {@code protectionBuyer} property. */ private final MetaProperty<ExternalId> _protectionBuyer = DirectMetaProperty.ofReadWrite( this, "protectionBuyer", CreditDefaultSwapOptionSecurity.class, ExternalId.class); /** * The meta-property for the {@code protectionSeller} property. */ private final MetaProperty<ExternalId> _protectionSeller = DirectMetaProperty.ofReadWrite( this, "protectionSeller", CreditDefaultSwapOptionSecurity.class, ExternalId.class); /** * The meta-property for the {@code startDate} property. */ private final MetaProperty<ZonedDateTime> _startDate = DirectMetaProperty.ofReadWrite( this, "startDate", CreditDefaultSwapOptionSecurity.class, ZonedDateTime.class); /** * The meta-property for the {@code maturityDate} property. */ private final MetaProperty<ZonedDateTime> _maturityDate = DirectMetaProperty.ofReadWrite( this, "maturityDate", CreditDefaultSwapOptionSecurity.class, ZonedDateTime.class); /** * The meta-property for the {@code currency} property. */ private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite( this, "currency", CreditDefaultSwapOptionSecurity.class, Currency.class); /** * The meta-property for the {@code notional} property. */ private final MetaProperty<Double> _notional = DirectMetaProperty.ofReadWrite( this, "notional", CreditDefaultSwapOptionSecurity.class, Double.class); /** * The meta-property for the {@code strike} property. */ private final MetaProperty<Double> _strike = DirectMetaProperty.ofReadWrite( this, "strike", CreditDefaultSwapOptionSecurity.class, Double.class); /** * The meta-property for the {@code knockOut} property. */ private final MetaProperty<Boolean> _knockOut = DirectMetaProperty.ofReadWrite( this, "knockOut", CreditDefaultSwapOptionSecurity.class, Boolean.TYPE); /** * The meta-property for the {@code payer} property. */ private final MetaProperty<Boolean> _payer = DirectMetaProperty.ofReadWrite( this, "payer", CreditDefaultSwapOptionSecurity.class, Boolean.TYPE); /** * The meta-property for the {@code exerciseType} property. */ private final MetaProperty<ExerciseType> _exerciseType = DirectMetaProperty.ofReadWrite( this, "exerciseType", CreditDefaultSwapOptionSecurity.class, ExerciseType.class); /** * The meta-property for the {@code underlyingId} property. */ private final MetaProperty<ExternalId> _underlyingId = DirectMetaProperty.ofReadWrite( this, "underlyingId", CreditDefaultSwapOptionSecurity.class, ExternalId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "buy", "protectionBuyer", "protectionSeller", "startDate", "maturityDate", "currency", "notional", "strike", "knockOut", "payer", "exerciseType", "underlyingId"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 97926: // buy return _buy; case 2087835226: // protectionBuyer return _protectionBuyer; case 769920952: // protectionSeller return _protectionSeller; case -2129778896: // startDate return _startDate; case -414641441: // maturityDate return _maturityDate; case 575402001: // currency return _currency; case 1585636160: // notional return _notional; case -891985998: // strike return _strike; case -384166438: // knockOut return _knockOut; case 106443605: // payer return _payer; case -466331342: // exerciseType return _exerciseType; case -771625640: // underlyingId return _underlyingId; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends CreditDefaultSwapOptionSecurity> builder() { return new DirectBeanBuilder<CreditDefaultSwapOptionSecurity>(new CreditDefaultSwapOptionSecurity()); } @Override public Class<? extends CreditDefaultSwapOptionSecurity> beanType() { return CreditDefaultSwapOptionSecurity.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code buy} property. * @return the meta-property, not null */ public final MetaProperty<Boolean> buy() { return _buy; } /** * The meta-property for the {@code protectionBuyer} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> protectionBuyer() { return _protectionBuyer; } /** * The meta-property for the {@code protectionSeller} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> protectionSeller() { return _protectionSeller; } /** * The meta-property for the {@code startDate} property. * @return the meta-property, not null */ public final MetaProperty<ZonedDateTime> startDate() { return _startDate; } /** * The meta-property for the {@code maturityDate} property. * @return the meta-property, not null */ public final MetaProperty<ZonedDateTime> maturityDate() { return _maturityDate; } /** * 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 notional} property. * @return the meta-property, not null */ public final MetaProperty<Double> notional() { return _notional; } /** * The meta-property for the {@code strike} property. * @return the meta-property, not null */ public final MetaProperty<Double> strike() { return _strike; } /** * The meta-property for the {@code knockOut} property. * @return the meta-property, not null */ public final MetaProperty<Boolean> knockOut() { return _knockOut; } /** * The meta-property for the {@code payer} property. * @return the meta-property, not null */ public final MetaProperty<Boolean> payer() { return _payer; } /** * The meta-property for the {@code exerciseType} property. * @return the meta-property, not null */ public final MetaProperty<ExerciseType> exerciseType() { return _exerciseType; } /** * The meta-property for the {@code underlyingId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> underlyingId() { return _underlyingId; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 97926: // buy return ((CreditDefaultSwapOptionSecurity) bean).isBuy(); case 2087835226: // protectionBuyer return ((CreditDefaultSwapOptionSecurity) bean).getProtectionBuyer(); case 769920952: // protectionSeller return ((CreditDefaultSwapOptionSecurity) bean).getProtectionSeller(); case -2129778896: // startDate return ((CreditDefaultSwapOptionSecurity) bean).getStartDate(); case -414641441: // maturityDate return ((CreditDefaultSwapOptionSecurity) bean).getMaturityDate(); case 575402001: // currency return ((CreditDefaultSwapOptionSecurity) bean).getCurrency(); case 1585636160: // notional return ((CreditDefaultSwapOptionSecurity) bean).getNotional(); case -891985998: // strike return ((CreditDefaultSwapOptionSecurity) bean).getStrike(); case -384166438: // knockOut return ((CreditDefaultSwapOptionSecurity) bean).isKnockOut(); case 106443605: // payer return ((CreditDefaultSwapOptionSecurity) bean).isPayer(); case -466331342: // exerciseType return ((CreditDefaultSwapOptionSecurity) bean).getExerciseType(); case -771625640: // underlyingId return ((CreditDefaultSwapOptionSecurity) bean).getUnderlyingId(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 97926: // buy ((CreditDefaultSwapOptionSecurity) bean).setBuy((Boolean) newValue); return; case 2087835226: // protectionBuyer ((CreditDefaultSwapOptionSecurity) bean).setProtectionBuyer((ExternalId) newValue); return; case 769920952: // protectionSeller ((CreditDefaultSwapOptionSecurity) bean).setProtectionSeller((ExternalId) newValue); return; case -2129778896: // startDate ((CreditDefaultSwapOptionSecurity) bean).setStartDate((ZonedDateTime) newValue); return; case -414641441: // maturityDate ((CreditDefaultSwapOptionSecurity) bean).setMaturityDate((ZonedDateTime) newValue); return; case 575402001: // currency ((CreditDefaultSwapOptionSecurity) bean).setCurrency((Currency) newValue); return; case 1585636160: // notional ((CreditDefaultSwapOptionSecurity) bean).setNotional((Double) newValue); return; case -891985998: // strike ((CreditDefaultSwapOptionSecurity) bean).setStrike((Double) newValue); return; case -384166438: // knockOut ((CreditDefaultSwapOptionSecurity) bean).setKnockOut((Boolean) newValue); return; case 106443605: // payer ((CreditDefaultSwapOptionSecurity) bean).setPayer((Boolean) newValue); return; case -466331342: // exerciseType ((CreditDefaultSwapOptionSecurity) bean).setExerciseType((ExerciseType) newValue); return; case -771625640: // underlyingId ((CreditDefaultSwapOptionSecurity) bean).setUnderlyingId((ExternalId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._protectionBuyer, "protectionBuyer"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._protectionSeller, "protectionSeller"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._startDate, "startDate"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._maturityDate, "maturityDate"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._currency, "currency"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._notional, "notional"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._strike, "strike"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._exerciseType, "exerciseType"); JodaBeanUtils.notNull(((CreditDefaultSwapOptionSecurity) bean)._underlyingId, "underlyingId"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }