/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.security.capfloor;
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.convention.daycount.DayCount;
import com.opengamma.financial.convention.frequency.Frequency;
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;
/**
* A security for cap/floor.
*/
@BeanDefinition
@SecurityDescription(type = CapFloorSecurity.SECURITY_TYPE, description = "Cap floor")
public class CapFloorSecurity extends FinancialSecurity {
/** Serialization version. */
private static final long serialVersionUID = 1L;
/**
* The security type.
*/
public static final String SECURITY_TYPE = "CAP-FLOOR";
/**
* The start date.
*/
@PropertyDefinition(validate = "notNull")
private ZonedDateTime _startDate;
/**
* The maturity date.
*/
@PropertyDefinition(validate = "notNull")
private ZonedDateTime _maturityDate;
/**
* The notional.
*/
@PropertyDefinition
private double _notional;
/**
* The underlying identifier.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _underlyingId;
/**
* The strike.
*/
@PropertyDefinition
private double _strike;
/**
* The frequency.
*/
@PropertyDefinition(validate = "notNull")
private Frequency _frequency;
/**
* The currency.
*/
@PropertyDefinition(validate = "notNull")
private Currency _currency;
/**
* The day count.
*/
@PropertyDefinition(validate = "notNull")
private DayCount _dayCount;
/**
* The payer flag.
*/
@PropertyDefinition
private boolean _payer;
/**
* The cap flag.
*/
@PropertyDefinition
private boolean _cap;
/**
* The IBOR flag.
*/
@PropertyDefinition
private boolean _ibor;
CapFloorSecurity() { //For builder
super(SECURITY_TYPE);
}
public CapFloorSecurity(ZonedDateTime startDate, ZonedDateTime maturityDate, double notional, ExternalId underlyingIdentifier, double strike,
Frequency frequency, Currency currency, DayCount dayCount, boolean payer, boolean cap, boolean ibor) {
super(SECURITY_TYPE);
setStartDate(startDate);
setMaturityDate(maturityDate);
setNotional(notional);
setUnderlyingId(underlyingIdentifier);
setStrike(strike);
setFrequency(frequency);
setCurrency(currency);
setDayCount(dayCount);
setPayer(payer);
setCap(cap);
setIbor(ibor);
}
//-------------------------------------------------------------------------
@Override
public final <T> T accept(FinancialSecurityVisitor<T> visitor) {
return visitor.visitCapFloorSecurity(this);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code CapFloorSecurity}.
* @return the meta-bean, not null
*/
public static CapFloorSecurity.Meta meta() {
return CapFloorSecurity.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(CapFloorSecurity.Meta.INSTANCE);
}
@Override
public CapFloorSecurity.Meta metaBean() {
return CapFloorSecurity.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* 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 notional.
* @return the value of the property
*/
public double getNotional() {
return _notional;
}
/**
* Sets the notional.
* @param notional the new value of the property
*/
public void setNotional(double 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 underlying identifier.
* @return the value of the property, not null
*/
public ExternalId getUnderlyingId() {
return _underlyingId;
}
/**
* Sets the underlying identifier.
* @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);
}
//-----------------------------------------------------------------------
/**
* Gets the strike.
* @return the value of the property
*/
public double getStrike() {
return _strike;
}
/**
* Sets the strike.
* @param strike the new value of the property
*/
public void setStrike(double 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 frequency.
* @return the value of the property, not null
*/
public Frequency getFrequency() {
return _frequency;
}
/**
* Sets the frequency.
* @param frequency the new value of the property, not null
*/
public void setFrequency(Frequency frequency) {
JodaBeanUtils.notNull(frequency, "frequency");
this._frequency = frequency;
}
/**
* Gets the the {@code frequency} property.
* @return the property, not null
*/
public final Property<Frequency> frequency() {
return metaBean().frequency().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 day count.
* @return the value of the property, not null
*/
public DayCount getDayCount() {
return _dayCount;
}
/**
* Sets the day count.
* @param dayCount the new value of the property, not null
*/
public void setDayCount(DayCount dayCount) {
JodaBeanUtils.notNull(dayCount, "dayCount");
this._dayCount = dayCount;
}
/**
* Gets the the {@code dayCount} property.
* @return the property, not null
*/
public final Property<DayCount> dayCount() {
return metaBean().dayCount().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the payer flag.
* @return the value of the property
*/
public boolean isPayer() {
return _payer;
}
/**
* Sets the payer flag.
* @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 cap flag.
* @return the value of the property
*/
public boolean isCap() {
return _cap;
}
/**
* Sets the cap flag.
* @param cap the new value of the property
*/
public void setCap(boolean cap) {
this._cap = cap;
}
/**
* Gets the the {@code cap} property.
* @return the property, not null
*/
public final Property<Boolean> cap() {
return metaBean().cap().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the IBOR flag.
* @return the value of the property
*/
public boolean isIbor() {
return _ibor;
}
/**
* Sets the IBOR flag.
* @param ibor the new value of the property
*/
public void setIbor(boolean ibor) {
this._ibor = ibor;
}
/**
* Gets the the {@code ibor} property.
* @return the property, not null
*/
public final Property<Boolean> ibor() {
return metaBean().ibor().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public CapFloorSecurity clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
CapFloorSecurity other = (CapFloorSecurity) obj;
return JodaBeanUtils.equal(getStartDate(), other.getStartDate()) &&
JodaBeanUtils.equal(getMaturityDate(), other.getMaturityDate()) &&
JodaBeanUtils.equal(getNotional(), other.getNotional()) &&
JodaBeanUtils.equal(getUnderlyingId(), other.getUnderlyingId()) &&
JodaBeanUtils.equal(getStrike(), other.getStrike()) &&
JodaBeanUtils.equal(getFrequency(), other.getFrequency()) &&
JodaBeanUtils.equal(getCurrency(), other.getCurrency()) &&
JodaBeanUtils.equal(getDayCount(), other.getDayCount()) &&
(isPayer() == other.isPayer()) &&
(isCap() == other.isCap()) &&
(isIbor() == other.isIbor()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getStartDate());
hash = hash * 31 + JodaBeanUtils.hashCode(getMaturityDate());
hash = hash * 31 + JodaBeanUtils.hashCode(getNotional());
hash = hash * 31 + JodaBeanUtils.hashCode(getUnderlyingId());
hash = hash * 31 + JodaBeanUtils.hashCode(getStrike());
hash = hash * 31 + JodaBeanUtils.hashCode(getFrequency());
hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency());
hash = hash * 31 + JodaBeanUtils.hashCode(getDayCount());
hash = hash * 31 + JodaBeanUtils.hashCode(isPayer());
hash = hash * 31 + JodaBeanUtils.hashCode(isCap());
hash = hash * 31 + JodaBeanUtils.hashCode(isIbor());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(384);
buf.append("CapFloorSecurity{");
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("startDate").append('=').append(JodaBeanUtils.toString(getStartDate())).append(',').append(' ');
buf.append("maturityDate").append('=').append(JodaBeanUtils.toString(getMaturityDate())).append(',').append(' ');
buf.append("notional").append('=').append(JodaBeanUtils.toString(getNotional())).append(',').append(' ');
buf.append("underlyingId").append('=').append(JodaBeanUtils.toString(getUnderlyingId())).append(',').append(' ');
buf.append("strike").append('=').append(JodaBeanUtils.toString(getStrike())).append(',').append(' ');
buf.append("frequency").append('=').append(JodaBeanUtils.toString(getFrequency())).append(',').append(' ');
buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' ');
buf.append("dayCount").append('=').append(JodaBeanUtils.toString(getDayCount())).append(',').append(' ');
buf.append("payer").append('=').append(JodaBeanUtils.toString(isPayer())).append(',').append(' ');
buf.append("cap").append('=').append(JodaBeanUtils.toString(isCap())).append(',').append(' ');
buf.append("ibor").append('=').append(JodaBeanUtils.toString(isIbor())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code CapFloorSecurity}.
*/
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 startDate} property.
*/
private final MetaProperty<ZonedDateTime> _startDate = DirectMetaProperty.ofReadWrite(
this, "startDate", CapFloorSecurity.class, ZonedDateTime.class);
/**
* The meta-property for the {@code maturityDate} property.
*/
private final MetaProperty<ZonedDateTime> _maturityDate = DirectMetaProperty.ofReadWrite(
this, "maturityDate", CapFloorSecurity.class, ZonedDateTime.class);
/**
* The meta-property for the {@code notional} property.
*/
private final MetaProperty<Double> _notional = DirectMetaProperty.ofReadWrite(
this, "notional", CapFloorSecurity.class, Double.TYPE);
/**
* The meta-property for the {@code underlyingId} property.
*/
private final MetaProperty<ExternalId> _underlyingId = DirectMetaProperty.ofReadWrite(
this, "underlyingId", CapFloorSecurity.class, ExternalId.class);
/**
* The meta-property for the {@code strike} property.
*/
private final MetaProperty<Double> _strike = DirectMetaProperty.ofReadWrite(
this, "strike", CapFloorSecurity.class, Double.TYPE);
/**
* The meta-property for the {@code frequency} property.
*/
private final MetaProperty<Frequency> _frequency = DirectMetaProperty.ofReadWrite(
this, "frequency", CapFloorSecurity.class, Frequency.class);
/**
* The meta-property for the {@code currency} property.
*/
private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite(
this, "currency", CapFloorSecurity.class, Currency.class);
/**
* The meta-property for the {@code dayCount} property.
*/
private final MetaProperty<DayCount> _dayCount = DirectMetaProperty.ofReadWrite(
this, "dayCount", CapFloorSecurity.class, DayCount.class);
/**
* The meta-property for the {@code payer} property.
*/
private final MetaProperty<Boolean> _payer = DirectMetaProperty.ofReadWrite(
this, "payer", CapFloorSecurity.class, Boolean.TYPE);
/**
* The meta-property for the {@code cap} property.
*/
private final MetaProperty<Boolean> _cap = DirectMetaProperty.ofReadWrite(
this, "cap", CapFloorSecurity.class, Boolean.TYPE);
/**
* The meta-property for the {@code ibor} property.
*/
private final MetaProperty<Boolean> _ibor = DirectMetaProperty.ofReadWrite(
this, "ibor", CapFloorSecurity.class, Boolean.TYPE);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"startDate",
"maturityDate",
"notional",
"underlyingId",
"strike",
"frequency",
"currency",
"dayCount",
"payer",
"cap",
"ibor");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -2129778896: // startDate
return _startDate;
case -414641441: // maturityDate
return _maturityDate;
case 1585636160: // notional
return _notional;
case -771625640: // underlyingId
return _underlyingId;
case -891985998: // strike
return _strike;
case -70023844: // frequency
return _frequency;
case 575402001: // currency
return _currency;
case 1905311443: // dayCount
return _dayCount;
case 106443605: // payer
return _payer;
case 98258: // cap
return _cap;
case 3225788: // ibor
return _ibor;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends CapFloorSecurity> builder() {
return new DirectBeanBuilder<CapFloorSecurity>(new CapFloorSecurity());
}
@Override
public Class<? extends CapFloorSecurity> beanType() {
return CapFloorSecurity.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* 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 notional} property.
* @return the meta-property, not null
*/
public final MetaProperty<Double> notional() {
return _notional;
}
/**
* The meta-property for the {@code underlyingId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> underlyingId() {
return _underlyingId;
}
/**
* 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 frequency} property.
* @return the meta-property, not null
*/
public final MetaProperty<Frequency> frequency() {
return _frequency;
}
/**
* 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 dayCount} property.
* @return the meta-property, not null
*/
public final MetaProperty<DayCount> dayCount() {
return _dayCount;
}
/**
* 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 cap} property.
* @return the meta-property, not null
*/
public final MetaProperty<Boolean> cap() {
return _cap;
}
/**
* The meta-property for the {@code ibor} property.
* @return the meta-property, not null
*/
public final MetaProperty<Boolean> ibor() {
return _ibor;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -2129778896: // startDate
return ((CapFloorSecurity) bean).getStartDate();
case -414641441: // maturityDate
return ((CapFloorSecurity) bean).getMaturityDate();
case 1585636160: // notional
return ((CapFloorSecurity) bean).getNotional();
case -771625640: // underlyingId
return ((CapFloorSecurity) bean).getUnderlyingId();
case -891985998: // strike
return ((CapFloorSecurity) bean).getStrike();
case -70023844: // frequency
return ((CapFloorSecurity) bean).getFrequency();
case 575402001: // currency
return ((CapFloorSecurity) bean).getCurrency();
case 1905311443: // dayCount
return ((CapFloorSecurity) bean).getDayCount();
case 106443605: // payer
return ((CapFloorSecurity) bean).isPayer();
case 98258: // cap
return ((CapFloorSecurity) bean).isCap();
case 3225788: // ibor
return ((CapFloorSecurity) bean).isIbor();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -2129778896: // startDate
((CapFloorSecurity) bean).setStartDate((ZonedDateTime) newValue);
return;
case -414641441: // maturityDate
((CapFloorSecurity) bean).setMaturityDate((ZonedDateTime) newValue);
return;
case 1585636160: // notional
((CapFloorSecurity) bean).setNotional((Double) newValue);
return;
case -771625640: // underlyingId
((CapFloorSecurity) bean).setUnderlyingId((ExternalId) newValue);
return;
case -891985998: // strike
((CapFloorSecurity) bean).setStrike((Double) newValue);
return;
case -70023844: // frequency
((CapFloorSecurity) bean).setFrequency((Frequency) newValue);
return;
case 575402001: // currency
((CapFloorSecurity) bean).setCurrency((Currency) newValue);
return;
case 1905311443: // dayCount
((CapFloorSecurity) bean).setDayCount((DayCount) newValue);
return;
case 106443605: // payer
((CapFloorSecurity) bean).setPayer((Boolean) newValue);
return;
case 98258: // cap
((CapFloorSecurity) bean).setCap((Boolean) newValue);
return;
case 3225788: // ibor
((CapFloorSecurity) bean).setIbor((Boolean) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((CapFloorSecurity) bean)._startDate, "startDate");
JodaBeanUtils.notNull(((CapFloorSecurity) bean)._maturityDate, "maturityDate");
JodaBeanUtils.notNull(((CapFloorSecurity) bean)._underlyingId, "underlyingId");
JodaBeanUtils.notNull(((CapFloorSecurity) bean)._frequency, "frequency");
JodaBeanUtils.notNull(((CapFloorSecurity) bean)._currency, "currency");
JodaBeanUtils.notNull(((CapFloorSecurity) bean)._dayCount, "dayCount");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}