/** * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.security.future; 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.security.FinancialSecurityVisitor; import com.opengamma.id.ExternalId; import com.opengamma.util.money.Currency; import com.opengamma.util.time.Expiry; /** * A security for deliverable swap futures */ @BeanDefinition public class DeliverableSwapFutureSecurity extends FutureSecurity { /** Serialization version */ private static final long serialVersionUID = 1L; /** * The underlying swap identifier. */ @PropertyDefinition(validate = "notNull") private ExternalId _underlyingSwapId; /** * The swap notional. */ @PropertyDefinition(validate = "notNull") private double _notional; /** * Creates an empty instance. */ public DeliverableSwapFutureSecurity() { super(); } /** * @param expiry The expiry, not null * @param tradingExchange The trading exchange, not null * @param settlementExchange The settlement exchange, not null * @param currency The currency, not null * @param unitAmount The unit amount, not null * @param category The future category, not null * @param underlyingSwapId A reference to the underlying swap, not null * @param notional The swap notional, not null */ public DeliverableSwapFutureSecurity(final Expiry expiry, final String tradingExchange, final String settlementExchange, final Currency currency, final double unitAmount, final String category, final ExternalId underlyingSwapId, final double notional) { super(expiry, tradingExchange, settlementExchange, currency, unitAmount, category); setUnderlyingSwapId(underlyingSwapId); setNotional(notional); } @Override public <T> T accept(final FinancialSecurityVisitor<T> visitor) { return visitor.visitDeliverableSwapFutureSecurity(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code DeliverableSwapFutureSecurity}. * @return the meta-bean, not null */ public static DeliverableSwapFutureSecurity.Meta meta() { return DeliverableSwapFutureSecurity.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(DeliverableSwapFutureSecurity.Meta.INSTANCE); } @Override public DeliverableSwapFutureSecurity.Meta metaBean() { return DeliverableSwapFutureSecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the underlying swap identifier. * @return the value of the property, not null */ public ExternalId getUnderlyingSwapId() { return _underlyingSwapId; } /** * Sets the underlying swap identifier. * @param underlyingSwapId the new value of the property, not null */ public void setUnderlyingSwapId(ExternalId underlyingSwapId) { JodaBeanUtils.notNull(underlyingSwapId, "underlyingSwapId"); this._underlyingSwapId = underlyingSwapId; } /** * Gets the the {@code underlyingSwapId} property. * @return the property, not null */ public final Property<ExternalId> underlyingSwapId() { return metaBean().underlyingSwapId().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the swap notional. * @return the value of the property, not null */ public double getNotional() { return _notional; } /** * Sets the swap 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); } //----------------------------------------------------------------------- @Override public DeliverableSwapFutureSecurity clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { DeliverableSwapFutureSecurity other = (DeliverableSwapFutureSecurity) obj; return JodaBeanUtils.equal(getUnderlyingSwapId(), other.getUnderlyingSwapId()) && JodaBeanUtils.equal(getNotional(), other.getNotional()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getUnderlyingSwapId()); hash = hash * 31 + JodaBeanUtils.hashCode(getNotional()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(96); buf.append("DeliverableSwapFutureSecurity{"); 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("underlyingSwapId").append('=').append(JodaBeanUtils.toString(getUnderlyingSwapId())).append(',').append(' '); buf.append("notional").append('=').append(JodaBeanUtils.toString(getNotional())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code DeliverableSwapFutureSecurity}. */ public static class Meta extends FutureSecurity.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code underlyingSwapId} property. */ private final MetaProperty<ExternalId> _underlyingSwapId = DirectMetaProperty.ofReadWrite( this, "underlyingSwapId", DeliverableSwapFutureSecurity.class, ExternalId.class); /** * The meta-property for the {@code notional} property. */ private final MetaProperty<Double> _notional = DirectMetaProperty.ofReadWrite( this, "notional", DeliverableSwapFutureSecurity.class, Double.TYPE); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "underlyingSwapId", "notional"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 207977419: // underlyingSwapId return _underlyingSwapId; case 1585636160: // notional return _notional; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends DeliverableSwapFutureSecurity> builder() { return new DirectBeanBuilder<DeliverableSwapFutureSecurity>(new DeliverableSwapFutureSecurity()); } @Override public Class<? extends DeliverableSwapFutureSecurity> beanType() { return DeliverableSwapFutureSecurity.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code underlyingSwapId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> underlyingSwapId() { return _underlyingSwapId; } /** * The meta-property for the {@code notional} property. * @return the meta-property, not null */ public final MetaProperty<Double> notional() { return _notional; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 207977419: // underlyingSwapId return ((DeliverableSwapFutureSecurity) bean).getUnderlyingSwapId(); case 1585636160: // notional return ((DeliverableSwapFutureSecurity) bean).getNotional(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 207977419: // underlyingSwapId ((DeliverableSwapFutureSecurity) bean).setUnderlyingSwapId((ExternalId) newValue); return; case 1585636160: // notional ((DeliverableSwapFutureSecurity) bean).setNotional((Double) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((DeliverableSwapFutureSecurity) bean)._underlyingSwapId, "underlyingSwapId"); JodaBeanUtils.notNull(((DeliverableSwapFutureSecurity) bean)._notional, "notional"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }