/** * 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.businessday.BusinessDayConvention; 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 deposit rates. */ @BeanDefinition public class DepositConvention extends FinancialConvention { /** * Type of the convention. */ public static final ConventionType TYPE = ConventionType.of("Deposit"); /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The day count. */ @PropertyDefinition(validate = "notNull") private DayCount _dayCount; /** * The business day convention. */ @PropertyDefinition(validate = "notNull") private BusinessDayConvention _businessDayConvention; /** * The number of settlement days. */ @PropertyDefinition private int _settlementDays; /** * Whether dates follow the end-of-month rule. */ @PropertyDefinition private boolean _isEOM; /** * The currency. */ @PropertyDefinition(validate = "notNull") private Currency _currency; /** * The region calendar. */ @PropertyDefinition(validate = "notNull") private ExternalId _regionCalendar; /** * Creates an instance. */ protected DepositConvention() { super(); } /** * Creates an instance. * * @param name the name of the convention, not null * @param externalIdBundle the external identifiers for this convention, not null * @param dayCount the day-count, not null * @param businessDayConvention the businessDayConvention, not null * @param settlementDays the number of settlement days * @param isEOM true if the dates follow the end-of-month rule * @param currency the currency, not null * @param regionCalendar the identifier for the region calendar, not null */ public DepositConvention( final String name, final ExternalIdBundle externalIdBundle, final DayCount dayCount, final BusinessDayConvention businessDayConvention, final int settlementDays, final boolean isEOM, final Currency currency, final ExternalId regionCalendar) { super(name, externalIdBundle); setDayCount(dayCount); setBusinessDayConvention(businessDayConvention); setSettlementDays(settlementDays); setIsEOM(isEOM); 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.visitDepositConvention(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code DepositConvention}. * @return the meta-bean, not null */ public static DepositConvention.Meta meta() { return DepositConvention.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(DepositConvention.Meta.INSTANCE); } @Override public DepositConvention.Meta metaBean() { return DepositConvention.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 business day convention. * @return the value of the property, not null */ public BusinessDayConvention getBusinessDayConvention() { return _businessDayConvention; } /** * Sets the business day convention. * @param businessDayConvention the new value of the property, not null */ public void setBusinessDayConvention(BusinessDayConvention businessDayConvention) { JodaBeanUtils.notNull(businessDayConvention, "businessDayConvention"); this._businessDayConvention = businessDayConvention; } /** * Gets the the {@code businessDayConvention} property. * @return the property, not null */ public final Property<BusinessDayConvention> businessDayConvention() { return metaBean().businessDayConvention().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the number of settlement days. * @return the value of the property */ public int getSettlementDays() { return _settlementDays; } /** * Sets the number of settlement days. * @param settlementDays the new value of the property */ public void setSettlementDays(int settlementDays) { this._settlementDays = settlementDays; } /** * Gets the the {@code settlementDays} property. * @return the property, not null */ public final Property<Integer> settlementDays() { return metaBean().settlementDays().createProperty(this); } //----------------------------------------------------------------------- /** * Gets whether dates follow the end-of-month rule. * @return the value of the property */ public boolean isIsEOM() { return _isEOM; } /** * Sets whether dates follow the end-of-month rule. * @param isEOM the new value of the property */ public void setIsEOM(boolean isEOM) { this._isEOM = isEOM; } /** * Gets the the {@code isEOM} property. * @return the property, not null */ public final Property<Boolean> isEOM() { return metaBean().isEOM().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 DepositConvention clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { DepositConvention other = (DepositConvention) obj; return JodaBeanUtils.equal(getDayCount(), other.getDayCount()) && JodaBeanUtils.equal(getBusinessDayConvention(), other.getBusinessDayConvention()) && (getSettlementDays() == other.getSettlementDays()) && (isIsEOM() == other.isIsEOM()) && 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(getBusinessDayConvention()); hash = hash * 31 + JodaBeanUtils.hashCode(getSettlementDays()); hash = hash * 31 + JodaBeanUtils.hashCode(isIsEOM()); hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getRegionCalendar()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(224); buf.append("DepositConvention{"); 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("businessDayConvention").append('=').append(JodaBeanUtils.toString(getBusinessDayConvention())).append(',').append(' '); buf.append("settlementDays").append('=').append(JodaBeanUtils.toString(getSettlementDays())).append(',').append(' '); buf.append("isEOM").append('=').append(JodaBeanUtils.toString(isIsEOM())).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 DepositConvention}. */ 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", DepositConvention.class, DayCount.class); /** * The meta-property for the {@code businessDayConvention} property. */ private final MetaProperty<BusinessDayConvention> _businessDayConvention = DirectMetaProperty.ofReadWrite( this, "businessDayConvention", DepositConvention.class, BusinessDayConvention.class); /** * The meta-property for the {@code settlementDays} property. */ private final MetaProperty<Integer> _settlementDays = DirectMetaProperty.ofReadWrite( this, "settlementDays", DepositConvention.class, Integer.TYPE); /** * The meta-property for the {@code isEOM} property. */ private final MetaProperty<Boolean> _isEOM = DirectMetaProperty.ofReadWrite( this, "isEOM", DepositConvention.class, Boolean.TYPE); /** * The meta-property for the {@code currency} property. */ private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite( this, "currency", DepositConvention.class, Currency.class); /** * The meta-property for the {@code regionCalendar} property. */ private final MetaProperty<ExternalId> _regionCalendar = DirectMetaProperty.ofReadWrite( this, "regionCalendar", DepositConvention.class, ExternalId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "dayCount", "businessDayConvention", "settlementDays", "isEOM", "currency", "regionCalendar"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 1905311443: // dayCount return _dayCount; case -1002835891: // businessDayConvention return _businessDayConvention; case -295948000: // settlementDays return _settlementDays; case 100464505: // isEOM return _isEOM; case 575402001: // currency return _currency; case 1932874322: // regionCalendar return _regionCalendar; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends DepositConvention> builder() { return new DirectBeanBuilder<DepositConvention>(new DepositConvention()); } @Override public Class<? extends DepositConvention> beanType() { return DepositConvention.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 businessDayConvention} property. * @return the meta-property, not null */ public final MetaProperty<BusinessDayConvention> businessDayConvention() { return _businessDayConvention; } /** * The meta-property for the {@code settlementDays} property. * @return the meta-property, not null */ public final MetaProperty<Integer> settlementDays() { return _settlementDays; } /** * The meta-property for the {@code isEOM} property. * @return the meta-property, not null */ public final MetaProperty<Boolean> isEOM() { return _isEOM; } /** * 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 ((DepositConvention) bean).getDayCount(); case -1002835891: // businessDayConvention return ((DepositConvention) bean).getBusinessDayConvention(); case -295948000: // settlementDays return ((DepositConvention) bean).getSettlementDays(); case 100464505: // isEOM return ((DepositConvention) bean).isIsEOM(); case 575402001: // currency return ((DepositConvention) bean).getCurrency(); case 1932874322: // regionCalendar return ((DepositConvention) 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 ((DepositConvention) bean).setDayCount((DayCount) newValue); return; case -1002835891: // businessDayConvention ((DepositConvention) bean).setBusinessDayConvention((BusinessDayConvention) newValue); return; case -295948000: // settlementDays ((DepositConvention) bean).setSettlementDays((Integer) newValue); return; case 100464505: // isEOM ((DepositConvention) bean).setIsEOM((Boolean) newValue); return; case 575402001: // currency ((DepositConvention) bean).setCurrency((Currency) newValue); return; case 1932874322: // regionCalendar ((DepositConvention) bean).setRegionCalendar((ExternalId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((DepositConvention) bean)._dayCount, "dayCount"); JodaBeanUtils.notNull(((DepositConvention) bean)._businessDayConvention, "businessDayConvention"); JodaBeanUtils.notNull(((DepositConvention) bean)._currency, "currency"); JodaBeanUtils.notNull(((DepositConvention) bean)._regionCalendar, "regionCalendar"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }