/** * Copyright (C) 2013 - 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 com.opengamma.core.convention.ConventionType; import com.opengamma.id.ExternalId; import com.opengamma.id.ExternalIdBundle; import com.opengamma.util.ArgumentChecker; /** * Convention for price-quoted deliverable swap futures (as traded on CME). */ @BeanDefinition public class DeliverablePriceQuotedSwapFutureConvention extends ExchangeTradedFutureAndOptionConvention { /** * Type of the convention. */ public static final ConventionType TYPE = ConventionType.of("DeliverablePriceQuotedSwapFuture"); /** Serialization version */ private static final long serialVersionUID = 1L; /** * The convention for the underlying swap. */ @PropertyDefinition(validate = "notNull") private ExternalId _swapConvention; /** * The notional for the future. */ @PropertyDefinition private double _notional; /** * For the builder. */ protected DeliverablePriceQuotedSwapFutureConvention() { super(); } /** * @param name The name of the convention, not null * @param externalIdBundle The external identifiers for this convention, not null * @param expiryConvention The expiry convention, not null * @param exchangeCalendar The exchange calendar, not null * @param swapConvention The underlying swap convention, not null * @param notional The notional of the future */ public DeliverablePriceQuotedSwapFutureConvention( final String name, final ExternalIdBundle externalIdBundle, final ExternalId expiryConvention, final ExternalId exchangeCalendar, final ExternalId swapConvention, final double notional) { super(name, externalIdBundle, expiryConvention, exchangeCalendar); setSwapConvention(swapConvention); setNotional(notional); } //------------------------------------------------------------------------- /** * Gets the type identifying this convention. * * @return the {@link #TYPE} constant, not null */ @Override public ConventionType getConventionType() { return TYPE; } /** * Accepts a visitor to manage traversal of the hierarchy. * * @param <T> the result type of the visitor * @param visitor the visitor, not null * @return the result */ @Override public <T> T accept(final FinancialConventionVisitor<T> visitor) { ArgumentChecker.notNull(visitor, "visitor"); return visitor.visitDeliverablePriceQuotedSwapFutureConvention(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code DeliverablePriceQuotedSwapFutureConvention}. * @return the meta-bean, not null */ public static DeliverablePriceQuotedSwapFutureConvention.Meta meta() { return DeliverablePriceQuotedSwapFutureConvention.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(DeliverablePriceQuotedSwapFutureConvention.Meta.INSTANCE); } @Override public DeliverablePriceQuotedSwapFutureConvention.Meta metaBean() { return DeliverablePriceQuotedSwapFutureConvention.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the convention for the underlying swap. * @return the value of the property, not null */ public ExternalId getSwapConvention() { return _swapConvention; } /** * Sets the convention for the underlying swap. * @param swapConvention the new value of the property, not null */ public void setSwapConvention(ExternalId swapConvention) { JodaBeanUtils.notNull(swapConvention, "swapConvention"); this._swapConvention = swapConvention; } /** * Gets the the {@code swapConvention} property. * @return the property, not null */ public final Property<ExternalId> swapConvention() { return metaBean().swapConvention().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the notional for the future. * @return the value of the property */ public double getNotional() { return _notional; } /** * Sets the notional for the future. * @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); } //----------------------------------------------------------------------- @Override public DeliverablePriceQuotedSwapFutureConvention clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { DeliverablePriceQuotedSwapFutureConvention other = (DeliverablePriceQuotedSwapFutureConvention) obj; return JodaBeanUtils.equal(getSwapConvention(), other.getSwapConvention()) && JodaBeanUtils.equal(getNotional(), other.getNotional()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getSwapConvention()); hash = hash * 31 + JodaBeanUtils.hashCode(getNotional()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(96); buf.append("DeliverablePriceQuotedSwapFutureConvention{"); 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("swapConvention").append('=').append(JodaBeanUtils.toString(getSwapConvention())).append(',').append(' '); buf.append("notional").append('=').append(JodaBeanUtils.toString(getNotional())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code DeliverablePriceQuotedSwapFutureConvention}. */ public static class Meta extends ExchangeTradedFutureAndOptionConvention.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code swapConvention} property. */ private final MetaProperty<ExternalId> _swapConvention = DirectMetaProperty.ofReadWrite( this, "swapConvention", DeliverablePriceQuotedSwapFutureConvention.class, ExternalId.class); /** * The meta-property for the {@code notional} property. */ private final MetaProperty<Double> _notional = DirectMetaProperty.ofReadWrite( this, "notional", DeliverablePriceQuotedSwapFutureConvention.class, Double.TYPE); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "swapConvention", "notional"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 1414180196: // swapConvention return _swapConvention; case 1585636160: // notional return _notional; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends DeliverablePriceQuotedSwapFutureConvention> builder() { return new DirectBeanBuilder<DeliverablePriceQuotedSwapFutureConvention>(new DeliverablePriceQuotedSwapFutureConvention()); } @Override public Class<? extends DeliverablePriceQuotedSwapFutureConvention> beanType() { return DeliverablePriceQuotedSwapFutureConvention.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code swapConvention} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> swapConvention() { return _swapConvention; } /** * 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 1414180196: // swapConvention return ((DeliverablePriceQuotedSwapFutureConvention) bean).getSwapConvention(); case 1585636160: // notional return ((DeliverablePriceQuotedSwapFutureConvention) bean).getNotional(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 1414180196: // swapConvention ((DeliverablePriceQuotedSwapFutureConvention) bean).setSwapConvention((ExternalId) newValue); return; case 1585636160: // notional ((DeliverablePriceQuotedSwapFutureConvention) bean).setNotional((Double) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((DeliverablePriceQuotedSwapFutureConvention) bean)._swapConvention, "swapConvention"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }