/** * Copyright (C) 2014 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.security.bond; 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.ZonedDateTime; import com.opengamma.financial.convention.daycount.DayCount; import com.opengamma.financial.convention.yield.YieldConvention; import com.opengamma.financial.security.FinancialSecurity; import com.opengamma.financial.security.FinancialSecurityVisitor; import com.opengamma.id.ExternalId; import com.opengamma.master.security.SecurityDescription; import com.opengamma.util.money.Currency; import com.opengamma.util.time.Expiry; /** * A security for bills. */ @BeanDefinition @SecurityDescription(type = BillSecurity.SECURITY_TYPE, description = "Bill") public class BillSecurity extends FinancialSecurity { /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The security type for bills. */ public static final String SECURITY_TYPE = "BILL"; /** * The currency. */ @PropertyDefinition(validate = "notNull") private Currency _currency; /** * The maturity date. */ @PropertyDefinition(validate = "notNull") private Expiry _maturityDate; /** * The issue date. */ @PropertyDefinition(validate = "notNull") private ZonedDateTime _issueDate; /** * The minimum increment. */ @PropertyDefinition private double _minimumIncrement; /** * The number of settlement days. */ @PropertyDefinition private int _daysToSettle; /** * The region identifier. */ @PropertyDefinition(validate = "notNull") private ExternalId _regionId; /** * The yield convention. */ @PropertyDefinition(validate = "notNull") private YieldConvention _yieldConvention; /** * The day count. */ @PropertyDefinition(validate = "notNull") private DayCount _dayCount; /** * The legal entity identifier. */ @PropertyDefinition(validate = "notNull") private ExternalId _legalEntityId; /** * For the builder. */ /* package */ BillSecurity() { super(SECURITY_TYPE); } /** * @param currency The currency, not null * @param maturityDate The maturity date, not null * @param issueDate The issue date, not null * @param minimumIncrement The minimum increment * @param daysToSettle The number of settlement days * @param regionId The region id, not null * @param yieldConvention The yield convention, not null * @param dayCount The day count, not null * @param legalEntityId The legal entity id, not null */ public BillSecurity(final Currency currency, final Expiry maturityDate, final ZonedDateTime issueDate, final double minimumIncrement, final int daysToSettle, final ExternalId regionId, final YieldConvention yieldConvention, final DayCount dayCount, final ExternalId legalEntityId) { super(SECURITY_TYPE); setCurrency(currency); setMaturityDate(maturityDate); setIssueDate(issueDate); setMinimumIncrement(minimumIncrement); setDaysToSettle(daysToSettle); setRegionId(regionId); setYieldConvention(yieldConvention); setDayCount(dayCount); setLegalEntityId(legalEntityId); } @Override public <T> T accept(final FinancialSecurityVisitor<T> visitor) { return visitor.visitBillSecurity(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code BillSecurity}. * @return the meta-bean, not null */ public static BillSecurity.Meta meta() { return BillSecurity.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(BillSecurity.Meta.INSTANCE); } @Override public BillSecurity.Meta metaBean() { return BillSecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * 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 maturity date. * @return the value of the property, not null */ public Expiry getMaturityDate() { return _maturityDate; } /** * Sets the maturity date. * @param maturityDate the new value of the property, not null */ public void setMaturityDate(Expiry maturityDate) { JodaBeanUtils.notNull(maturityDate, "maturityDate"); this._maturityDate = maturityDate; } /** * Gets the the {@code maturityDate} property. * @return the property, not null */ public final Property<Expiry> maturityDate() { return metaBean().maturityDate().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the issue date. * @return the value of the property, not null */ public ZonedDateTime getIssueDate() { return _issueDate; } /** * Sets the issue date. * @param issueDate the new value of the property, not null */ public void setIssueDate(ZonedDateTime issueDate) { JodaBeanUtils.notNull(issueDate, "issueDate"); this._issueDate = issueDate; } /** * Gets the the {@code issueDate} property. * @return the property, not null */ public final Property<ZonedDateTime> issueDate() { return metaBean().issueDate().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the minimum increment. * @return the value of the property */ public double getMinimumIncrement() { return _minimumIncrement; } /** * Sets the minimum increment. * @param minimumIncrement the new value of the property */ public void setMinimumIncrement(double minimumIncrement) { this._minimumIncrement = minimumIncrement; } /** * Gets the the {@code minimumIncrement} property. * @return the property, not null */ public final Property<Double> minimumIncrement() { return metaBean().minimumIncrement().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the number of settlement days. * @return the value of the property */ public int getDaysToSettle() { return _daysToSettle; } /** * Sets the number of settlement days. * @param daysToSettle the new value of the property */ public void setDaysToSettle(int daysToSettle) { this._daysToSettle = daysToSettle; } /** * Gets the the {@code daysToSettle} property. * @return the property, not null */ public final Property<Integer> daysToSettle() { return metaBean().daysToSettle().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the region identifier. * @return the value of the property, not null */ public ExternalId getRegionId() { return _regionId; } /** * Sets the region identifier. * @param regionId the new value of the property, not null */ public void setRegionId(ExternalId regionId) { JodaBeanUtils.notNull(regionId, "regionId"); this._regionId = regionId; } /** * Gets the the {@code regionId} property. * @return the property, not null */ public final Property<ExternalId> regionId() { return metaBean().regionId().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the yield convention. * @return the value of the property, not null */ public YieldConvention getYieldConvention() { return _yieldConvention; } /** * Sets the yield convention. * @param yieldConvention the new value of the property, not null */ public void setYieldConvention(YieldConvention yieldConvention) { JodaBeanUtils.notNull(yieldConvention, "yieldConvention"); this._yieldConvention = yieldConvention; } /** * Gets the the {@code yieldConvention} property. * @return the property, not null */ public final Property<YieldConvention> yieldConvention() { return metaBean().yieldConvention().createProperty(this); } //----------------------------------------------------------------------- /** * 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 legal entity identifier. * @return the value of the property, not null */ public ExternalId getLegalEntityId() { return _legalEntityId; } /** * Sets the legal entity identifier. * @param legalEntityId the new value of the property, not null */ public void setLegalEntityId(ExternalId legalEntityId) { JodaBeanUtils.notNull(legalEntityId, "legalEntityId"); this._legalEntityId = legalEntityId; } /** * Gets the the {@code legalEntityId} property. * @return the property, not null */ public final Property<ExternalId> legalEntityId() { return metaBean().legalEntityId().createProperty(this); } //----------------------------------------------------------------------- @Override public BillSecurity clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { BillSecurity other = (BillSecurity) obj; return JodaBeanUtils.equal(getCurrency(), other.getCurrency()) && JodaBeanUtils.equal(getMaturityDate(), other.getMaturityDate()) && JodaBeanUtils.equal(getIssueDate(), other.getIssueDate()) && JodaBeanUtils.equal(getMinimumIncrement(), other.getMinimumIncrement()) && (getDaysToSettle() == other.getDaysToSettle()) && JodaBeanUtils.equal(getRegionId(), other.getRegionId()) && JodaBeanUtils.equal(getYieldConvention(), other.getYieldConvention()) && JodaBeanUtils.equal(getDayCount(), other.getDayCount()) && JodaBeanUtils.equal(getLegalEntityId(), other.getLegalEntityId()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getMaturityDate()); hash = hash * 31 + JodaBeanUtils.hashCode(getIssueDate()); hash = hash * 31 + JodaBeanUtils.hashCode(getMinimumIncrement()); hash = hash * 31 + JodaBeanUtils.hashCode(getDaysToSettle()); hash = hash * 31 + JodaBeanUtils.hashCode(getRegionId()); hash = hash * 31 + JodaBeanUtils.hashCode(getYieldConvention()); hash = hash * 31 + JodaBeanUtils.hashCode(getDayCount()); hash = hash * 31 + JodaBeanUtils.hashCode(getLegalEntityId()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(320); buf.append("BillSecurity{"); 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("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' '); buf.append("maturityDate").append('=').append(JodaBeanUtils.toString(getMaturityDate())).append(',').append(' '); buf.append("issueDate").append('=').append(JodaBeanUtils.toString(getIssueDate())).append(',').append(' '); buf.append("minimumIncrement").append('=').append(JodaBeanUtils.toString(getMinimumIncrement())).append(',').append(' '); buf.append("daysToSettle").append('=').append(JodaBeanUtils.toString(getDaysToSettle())).append(',').append(' '); buf.append("regionId").append('=').append(JodaBeanUtils.toString(getRegionId())).append(',').append(' '); buf.append("yieldConvention").append('=').append(JodaBeanUtils.toString(getYieldConvention())).append(',').append(' '); buf.append("dayCount").append('=').append(JodaBeanUtils.toString(getDayCount())).append(',').append(' '); buf.append("legalEntityId").append('=').append(JodaBeanUtils.toString(getLegalEntityId())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code BillSecurity}. */ public static class Meta extends FinancialSecurity.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code currency} property. */ private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite( this, "currency", BillSecurity.class, Currency.class); /** * The meta-property for the {@code maturityDate} property. */ private final MetaProperty<Expiry> _maturityDate = DirectMetaProperty.ofReadWrite( this, "maturityDate", BillSecurity.class, Expiry.class); /** * The meta-property for the {@code issueDate} property. */ private final MetaProperty<ZonedDateTime> _issueDate = DirectMetaProperty.ofReadWrite( this, "issueDate", BillSecurity.class, ZonedDateTime.class); /** * The meta-property for the {@code minimumIncrement} property. */ private final MetaProperty<Double> _minimumIncrement = DirectMetaProperty.ofReadWrite( this, "minimumIncrement", BillSecurity.class, Double.TYPE); /** * The meta-property for the {@code daysToSettle} property. */ private final MetaProperty<Integer> _daysToSettle = DirectMetaProperty.ofReadWrite( this, "daysToSettle", BillSecurity.class, Integer.TYPE); /** * The meta-property for the {@code regionId} property. */ private final MetaProperty<ExternalId> _regionId = DirectMetaProperty.ofReadWrite( this, "regionId", BillSecurity.class, ExternalId.class); /** * The meta-property for the {@code yieldConvention} property. */ private final MetaProperty<YieldConvention> _yieldConvention = DirectMetaProperty.ofReadWrite( this, "yieldConvention", BillSecurity.class, YieldConvention.class); /** * The meta-property for the {@code dayCount} property. */ private final MetaProperty<DayCount> _dayCount = DirectMetaProperty.ofReadWrite( this, "dayCount", BillSecurity.class, DayCount.class); /** * The meta-property for the {@code legalEntityId} property. */ private final MetaProperty<ExternalId> _legalEntityId = DirectMetaProperty.ofReadWrite( this, "legalEntityId", BillSecurity.class, ExternalId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "currency", "maturityDate", "issueDate", "minimumIncrement", "daysToSettle", "regionId", "yieldConvention", "dayCount", "legalEntityId"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 575402001: // currency return _currency; case -414641441: // maturityDate return _maturityDate; case 184285223: // issueDate return _issueDate; case 1160465153: // minimumIncrement return _minimumIncrement; case 379523357: // daysToSettle return _daysToSettle; case -690339025: // regionId return _regionId; case -1895216418: // yieldConvention return _yieldConvention; case 1905311443: // dayCount return _dayCount; case 866287159: // legalEntityId return _legalEntityId; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends BillSecurity> builder() { return new DirectBeanBuilder<BillSecurity>(new BillSecurity()); } @Override public Class<? extends BillSecurity> beanType() { return BillSecurity.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * 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 maturityDate} property. * @return the meta-property, not null */ public final MetaProperty<Expiry> maturityDate() { return _maturityDate; } /** * The meta-property for the {@code issueDate} property. * @return the meta-property, not null */ public final MetaProperty<ZonedDateTime> issueDate() { return _issueDate; } /** * The meta-property for the {@code minimumIncrement} property. * @return the meta-property, not null */ public final MetaProperty<Double> minimumIncrement() { return _minimumIncrement; } /** * The meta-property for the {@code daysToSettle} property. * @return the meta-property, not null */ public final MetaProperty<Integer> daysToSettle() { return _daysToSettle; } /** * The meta-property for the {@code regionId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> regionId() { return _regionId; } /** * The meta-property for the {@code yieldConvention} property. * @return the meta-property, not null */ public final MetaProperty<YieldConvention> yieldConvention() { return _yieldConvention; } /** * 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 legalEntityId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> legalEntityId() { return _legalEntityId; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 575402001: // currency return ((BillSecurity) bean).getCurrency(); case -414641441: // maturityDate return ((BillSecurity) bean).getMaturityDate(); case 184285223: // issueDate return ((BillSecurity) bean).getIssueDate(); case 1160465153: // minimumIncrement return ((BillSecurity) bean).getMinimumIncrement(); case 379523357: // daysToSettle return ((BillSecurity) bean).getDaysToSettle(); case -690339025: // regionId return ((BillSecurity) bean).getRegionId(); case -1895216418: // yieldConvention return ((BillSecurity) bean).getYieldConvention(); case 1905311443: // dayCount return ((BillSecurity) bean).getDayCount(); case 866287159: // legalEntityId return ((BillSecurity) bean).getLegalEntityId(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 575402001: // currency ((BillSecurity) bean).setCurrency((Currency) newValue); return; case -414641441: // maturityDate ((BillSecurity) bean).setMaturityDate((Expiry) newValue); return; case 184285223: // issueDate ((BillSecurity) bean).setIssueDate((ZonedDateTime) newValue); return; case 1160465153: // minimumIncrement ((BillSecurity) bean).setMinimumIncrement((Double) newValue); return; case 379523357: // daysToSettle ((BillSecurity) bean).setDaysToSettle((Integer) newValue); return; case -690339025: // regionId ((BillSecurity) bean).setRegionId((ExternalId) newValue); return; case -1895216418: // yieldConvention ((BillSecurity) bean).setYieldConvention((YieldConvention) newValue); return; case 1905311443: // dayCount ((BillSecurity) bean).setDayCount((DayCount) newValue); return; case 866287159: // legalEntityId ((BillSecurity) bean).setLegalEntityId((ExternalId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((BillSecurity) bean)._currency, "currency"); JodaBeanUtils.notNull(((BillSecurity) bean)._maturityDate, "maturityDate"); JodaBeanUtils.notNull(((BillSecurity) bean)._issueDate, "issueDate"); JodaBeanUtils.notNull(((BillSecurity) bean)._regionId, "regionId"); JodaBeanUtils.notNull(((BillSecurity) bean)._yieldConvention, "yieldConvention"); JodaBeanUtils.notNull(((BillSecurity) bean)._dayCount, "dayCount"); JodaBeanUtils.notNull(((BillSecurity) bean)._legalEntityId, "legalEntityId"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }