/** * Copyright (C) 2014 - 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 org.threeten.bp.LocalDate; import com.opengamma.financial.convention.businessday.BusinessDayConvention; import com.opengamma.financial.convention.frequency.Frequency; import com.opengamma.financial.convention.rolldate.RollConvention; import com.opengamma.financial.security.FinancialSecurityVisitor; import com.opengamma.financial.security.irs.FloatingInterestRateSwapLeg; import com.opengamma.id.ExternalIdBundle; import com.opengamma.master.security.SecurityDescription; import com.opengamma.util.ArgumentChecker; import com.opengamma.util.money.Currency; /** * Equity total return swap security. */ @BeanDefinition @SecurityDescription(type = EquityTotalReturnSwapSecurity.SECURITY_TYPE, description = "Equity total return swap") public class EquityTotalReturnSwapSecurity extends TotalReturnSwapSecurity { /** Serialization version */ private static final long serialVersionUID = 1L; /** * The security type. */ public static final String SECURITY_TYPE = "EQUITY_TOTAL_RETURN_SWAP"; /** * The number of shares. */ @PropertyDefinition(validate = "notNull") private Double _numberOfShares; /** * The notional currency. */ @PropertyDefinition(validate = "notNull") private Currency _notionalCurrency; /** * The notional amount. */ @PropertyDefinition(validate = "notNull") private Double _notionalAmount; /** * The dividend percentage. */ @PropertyDefinition(validate = "notNull") private Double _dividendPercentage = 100.; /** * For the builder. */ /* package */EquityTotalReturnSwapSecurity() { super(SECURITY_TYPE); } /** * @param fundingLeg The funding leg, not null * @param assetId The asset external id bundle, not null * @param effectiveDate The effective date, not null * @param maturityDate The maturity date, not null * @param numberOfShares The number of shares, not null * @param notionalCurrency The currency of the notional, not null * @param notionalAmount The amount of the notional, not null * @param paymentSettlementDays The number of days to settle for the payments * @param paymentBusinessDayConvention The business day convention for the payments, not null * @param paymentFrequency The payment frequency, not null * @param rollConvention The payment roll convention, not null */ public EquityTotalReturnSwapSecurity(final FloatingInterestRateSwapLeg fundingLeg, final ExternalIdBundle assetId, final LocalDate effectiveDate, final LocalDate maturityDate, final Double numberOfShares, final Currency notionalCurrency, final Double notionalAmount, final int paymentSettlementDays, final BusinessDayConvention paymentBusinessDayConvention, final Frequency paymentFrequency, final RollConvention rollConvention) { super(SECURITY_TYPE, fundingLeg, assetId, effectiveDate, maturityDate, paymentSettlementDays, paymentBusinessDayConvention, paymentFrequency, rollConvention); setNumberOfShares(numberOfShares); setNotionalCurrency(notionalCurrency); setNotionalAmount(notionalAmount); } @Override public <T> T accept(final FinancialSecurityVisitor<T> visitor) { ArgumentChecker.notNull(visitor, "visitor"); return visitor.visitEquityTotalReturnSwapSecurity(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code EquityTotalReturnSwapSecurity}. * @return the meta-bean, not null */ public static EquityTotalReturnSwapSecurity.Meta meta() { return EquityTotalReturnSwapSecurity.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(EquityTotalReturnSwapSecurity.Meta.INSTANCE); } @Override public EquityTotalReturnSwapSecurity.Meta metaBean() { return EquityTotalReturnSwapSecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the number of shares. * @return the value of the property, not null */ public Double getNumberOfShares() { return _numberOfShares; } /** * Sets the number of shares. * @param numberOfShares the new value of the property, not null */ public void setNumberOfShares(Double numberOfShares) { JodaBeanUtils.notNull(numberOfShares, "numberOfShares"); this._numberOfShares = numberOfShares; } /** * Gets the the {@code numberOfShares} property. * @return the property, not null */ public final Property<Double> numberOfShares() { return metaBean().numberOfShares().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the notional currency. * @return the value of the property, not null */ public Currency getNotionalCurrency() { return _notionalCurrency; } /** * Sets the notional currency. * @param notionalCurrency the new value of the property, not null */ public void setNotionalCurrency(Currency notionalCurrency) { JodaBeanUtils.notNull(notionalCurrency, "notionalCurrency"); this._notionalCurrency = notionalCurrency; } /** * Gets the the {@code notionalCurrency} property. * @return the property, not null */ public final Property<Currency> notionalCurrency() { return metaBean().notionalCurrency().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the notional amount. * @return the value of the property, not null */ public Double getNotionalAmount() { return _notionalAmount; } /** * Sets the notional amount. * @param notionalAmount the new value of the property, not null */ public void setNotionalAmount(Double notionalAmount) { JodaBeanUtils.notNull(notionalAmount, "notionalAmount"); this._notionalAmount = notionalAmount; } /** * Gets the the {@code notionalAmount} property. * @return the property, not null */ public final Property<Double> notionalAmount() { return metaBean().notionalAmount().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the dividend percentage. * @return the value of the property, not null */ public Double getDividendPercentage() { return _dividendPercentage; } /** * Sets the dividend percentage. * @param dividendPercentage the new value of the property, not null */ public void setDividendPercentage(Double dividendPercentage) { JodaBeanUtils.notNull(dividendPercentage, "dividendPercentage"); this._dividendPercentage = dividendPercentage; } /** * Gets the the {@code dividendPercentage} property. * @return the property, not null */ public final Property<Double> dividendPercentage() { return metaBean().dividendPercentage().createProperty(this); } //----------------------------------------------------------------------- @Override public EquityTotalReturnSwapSecurity clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { EquityTotalReturnSwapSecurity other = (EquityTotalReturnSwapSecurity) obj; return JodaBeanUtils.equal(getNumberOfShares(), other.getNumberOfShares()) && JodaBeanUtils.equal(getNotionalCurrency(), other.getNotionalCurrency()) && JodaBeanUtils.equal(getNotionalAmount(), other.getNotionalAmount()) && JodaBeanUtils.equal(getDividendPercentage(), other.getDividendPercentage()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getNumberOfShares()); hash = hash * 31 + JodaBeanUtils.hashCode(getNotionalCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getNotionalAmount()); hash = hash * 31 + JodaBeanUtils.hashCode(getDividendPercentage()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("EquityTotalReturnSwapSecurity{"); 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("numberOfShares").append('=').append(JodaBeanUtils.toString(getNumberOfShares())).append(',').append(' '); buf.append("notionalCurrency").append('=').append(JodaBeanUtils.toString(getNotionalCurrency())).append(',').append(' '); buf.append("notionalAmount").append('=').append(JodaBeanUtils.toString(getNotionalAmount())).append(',').append(' '); buf.append("dividendPercentage").append('=').append(JodaBeanUtils.toString(getDividendPercentage())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code EquityTotalReturnSwapSecurity}. */ public static class Meta extends TotalReturnSwapSecurity.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code numberOfShares} property. */ private final MetaProperty<Double> _numberOfShares = DirectMetaProperty.ofReadWrite( this, "numberOfShares", EquityTotalReturnSwapSecurity.class, Double.class); /** * The meta-property for the {@code notionalCurrency} property. */ private final MetaProperty<Currency> _notionalCurrency = DirectMetaProperty.ofReadWrite( this, "notionalCurrency", EquityTotalReturnSwapSecurity.class, Currency.class); /** * The meta-property for the {@code notionalAmount} property. */ private final MetaProperty<Double> _notionalAmount = DirectMetaProperty.ofReadWrite( this, "notionalAmount", EquityTotalReturnSwapSecurity.class, Double.class); /** * The meta-property for the {@code dividendPercentage} property. */ private final MetaProperty<Double> _dividendPercentage = DirectMetaProperty.ofReadWrite( this, "dividendPercentage", EquityTotalReturnSwapSecurity.class, Double.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "numberOfShares", "notionalCurrency", "notionalAmount", "dividendPercentage"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 1922273172: // numberOfShares return _numberOfShares; case -1573783695: // notionalCurrency return _notionalCurrency; case -902123592: // notionalAmount return _notionalAmount; case -1094565911: // dividendPercentage return _dividendPercentage; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends EquityTotalReturnSwapSecurity> builder() { return new DirectBeanBuilder<EquityTotalReturnSwapSecurity>(new EquityTotalReturnSwapSecurity()); } @Override public Class<? extends EquityTotalReturnSwapSecurity> beanType() { return EquityTotalReturnSwapSecurity.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code numberOfShares} property. * @return the meta-property, not null */ public final MetaProperty<Double> numberOfShares() { return _numberOfShares; } /** * The meta-property for the {@code notionalCurrency} property. * @return the meta-property, not null */ public final MetaProperty<Currency> notionalCurrency() { return _notionalCurrency; } /** * The meta-property for the {@code notionalAmount} property. * @return the meta-property, not null */ public final MetaProperty<Double> notionalAmount() { return _notionalAmount; } /** * The meta-property for the {@code dividendPercentage} property. * @return the meta-property, not null */ public final MetaProperty<Double> dividendPercentage() { return _dividendPercentage; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 1922273172: // numberOfShares return ((EquityTotalReturnSwapSecurity) bean).getNumberOfShares(); case -1573783695: // notionalCurrency return ((EquityTotalReturnSwapSecurity) bean).getNotionalCurrency(); case -902123592: // notionalAmount return ((EquityTotalReturnSwapSecurity) bean).getNotionalAmount(); case -1094565911: // dividendPercentage return ((EquityTotalReturnSwapSecurity) bean).getDividendPercentage(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 1922273172: // numberOfShares ((EquityTotalReturnSwapSecurity) bean).setNumberOfShares((Double) newValue); return; case -1573783695: // notionalCurrency ((EquityTotalReturnSwapSecurity) bean).setNotionalCurrency((Currency) newValue); return; case -902123592: // notionalAmount ((EquityTotalReturnSwapSecurity) bean).setNotionalAmount((Double) newValue); return; case -1094565911: // dividendPercentage ((EquityTotalReturnSwapSecurity) bean).setDividendPercentage((Double) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((EquityTotalReturnSwapSecurity) bean)._numberOfShares, "numberOfShares"); JodaBeanUtils.notNull(((EquityTotalReturnSwapSecurity) bean)._notionalCurrency, "notionalCurrency"); JodaBeanUtils.notNull(((EquityTotalReturnSwapSecurity) bean)._notionalAmount, "notionalAmount"); JodaBeanUtils.notNull(((EquityTotalReturnSwapSecurity) bean)._dividendPercentage, "dividendPercentage"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }