/** * 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.financial.convention.daycount.DayCount; import com.opengamma.id.ExternalId; import com.opengamma.id.ExternalIdBundle; import com.opengamma.util.ArgumentChecker; import com.opengamma.util.money.Currency; /** * Convention for overnight indices. */ @BeanDefinition public class OvernightIndexConvention extends FinancialConvention { /** * Type of the convention. */ public static final ConventionType TYPE = ConventionType.of("OvernightIndex"); /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The day count. */ @PropertyDefinition(validate = "notNull") private DayCount _dayCount; /** * The publication lag. */ @PropertyDefinition private int _publicationLag; /** * The currency. */ @PropertyDefinition(validate = "notNull") private Currency _currency; /** * The region calendar. */ @PropertyDefinition(validate = "notNull") private ExternalId _regionCalendar; /** * Creates an instance. */ protected OvernightIndexConvention() { super(); } /** * Creates an instance. * * @param name the convention name, not null * @param externalIdBundle the external identifiers for this convention, not null * @param dayCount the day-count, not null * @param publicationLag the publication lag * @param currency the currency, not null * @param regionCalendar the region calendar, not null */ public OvernightIndexConvention( final String name, final ExternalIdBundle externalIdBundle, final DayCount dayCount, final int publicationLag, final Currency currency, final ExternalId regionCalendar) { super(name, externalIdBundle); setDayCount(dayCount); setPublicationLag(publicationLag); setCurrency(currency); setRegionCalendar(regionCalendar); } //------------------------------------------------------------------------- /** * 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.visitOvernightIndexConvention(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code OvernightIndexConvention}. * @return the meta-bean, not null */ public static OvernightIndexConvention.Meta meta() { return OvernightIndexConvention.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(OvernightIndexConvention.Meta.INSTANCE); } @Override public OvernightIndexConvention.Meta metaBean() { return OvernightIndexConvention.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * 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 publication lag. * @return the value of the property */ public int getPublicationLag() { return _publicationLag; } /** * Sets the publication lag. * @param publicationLag the new value of the property */ public void setPublicationLag(int publicationLag) { this._publicationLag = publicationLag; } /** * Gets the the {@code publicationLag} property. * @return the property, not null */ public final Property<Integer> publicationLag() { return metaBean().publicationLag().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 region calendar. * @return the value of the property, not null */ public ExternalId getRegionCalendar() { return _regionCalendar; } /** * Sets the region calendar. * @param regionCalendar the new value of the property, not null */ public void setRegionCalendar(ExternalId regionCalendar) { JodaBeanUtils.notNull(regionCalendar, "regionCalendar"); this._regionCalendar = regionCalendar; } /** * Gets the the {@code regionCalendar} property. * @return the property, not null */ public final Property<ExternalId> regionCalendar() { return metaBean().regionCalendar().createProperty(this); } //----------------------------------------------------------------------- @Override public OvernightIndexConvention clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { OvernightIndexConvention other = (OvernightIndexConvention) obj; return JodaBeanUtils.equal(getDayCount(), other.getDayCount()) && (getPublicationLag() == other.getPublicationLag()) && JodaBeanUtils.equal(getCurrency(), other.getCurrency()) && JodaBeanUtils.equal(getRegionCalendar(), other.getRegionCalendar()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getDayCount()); hash = hash * 31 + JodaBeanUtils.hashCode(getPublicationLag()); hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getRegionCalendar()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("OvernightIndexConvention{"); 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("dayCount").append('=').append(JodaBeanUtils.toString(getDayCount())).append(',').append(' '); buf.append("publicationLag").append('=').append(JodaBeanUtils.toString(getPublicationLag())).append(',').append(' '); buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' '); buf.append("regionCalendar").append('=').append(JodaBeanUtils.toString(getRegionCalendar())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code OvernightIndexConvention}. */ public static class Meta extends FinancialConvention.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code dayCount} property. */ private final MetaProperty<DayCount> _dayCount = DirectMetaProperty.ofReadWrite( this, "dayCount", OvernightIndexConvention.class, DayCount.class); /** * The meta-property for the {@code publicationLag} property. */ private final MetaProperty<Integer> _publicationLag = DirectMetaProperty.ofReadWrite( this, "publicationLag", OvernightIndexConvention.class, Integer.TYPE); /** * The meta-property for the {@code currency} property. */ private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite( this, "currency", OvernightIndexConvention.class, Currency.class); /** * The meta-property for the {@code regionCalendar} property. */ private final MetaProperty<ExternalId> _regionCalendar = DirectMetaProperty.ofReadWrite( this, "regionCalendar", OvernightIndexConvention.class, ExternalId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "dayCount", "publicationLag", "currency", "regionCalendar"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 1905311443: // dayCount return _dayCount; case 740181958: // publicationLag return _publicationLag; case 575402001: // currency return _currency; case 1932874322: // regionCalendar return _regionCalendar; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends OvernightIndexConvention> builder() { return new DirectBeanBuilder<OvernightIndexConvention>(new OvernightIndexConvention()); } @Override public Class<? extends OvernightIndexConvention> beanType() { return OvernightIndexConvention.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * 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 publicationLag} property. * @return the meta-property, not null */ public final MetaProperty<Integer> publicationLag() { return _publicationLag; } /** * 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 regionCalendar} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> regionCalendar() { return _regionCalendar; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 1905311443: // dayCount return ((OvernightIndexConvention) bean).getDayCount(); case 740181958: // publicationLag return ((OvernightIndexConvention) bean).getPublicationLag(); case 575402001: // currency return ((OvernightIndexConvention) bean).getCurrency(); case 1932874322: // regionCalendar return ((OvernightIndexConvention) bean).getRegionCalendar(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 1905311443: // dayCount ((OvernightIndexConvention) bean).setDayCount((DayCount) newValue); return; case 740181958: // publicationLag ((OvernightIndexConvention) bean).setPublicationLag((Integer) newValue); return; case 575402001: // currency ((OvernightIndexConvention) bean).setCurrency((Currency) newValue); return; case 1932874322: // regionCalendar ((OvernightIndexConvention) bean).setRegionCalendar((ExternalId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((OvernightIndexConvention) bean)._dayCount, "dayCount"); JodaBeanUtils.notNull(((OvernightIndexConvention) bean)._currency, "currency"); JodaBeanUtils.notNull(((OvernightIndexConvention) bean)._regionCalendar, "regionCalendar"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }