/** * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.security.equity; 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.FinancialSecurity; import com.opengamma.financial.security.FinancialSecurityVisitor; import com.opengamma.master.security.SecurityDescription; import com.opengamma.util.money.Currency; /** * A security for equities. */ @BeanDefinition @SecurityDescription(type = EquitySecurity.SECURITY_TYPE, description = "Equity") public class EquitySecurity extends FinancialSecurity { /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The security type. */ public static final String SECURITY_TYPE = "EQUITY"; /** * The short name. */ @PropertyDefinition private String _shortName; /** * The exchange. */ @PropertyDefinition(validate = "notNull") private String _exchange; /** * The exchange code. */ @PropertyDefinition(validate = "notNull") private String _exchangeCode; /** * The company name. */ @PropertyDefinition(validate = "notNull") private String _companyName; /** * The currency. */ @PropertyDefinition(validate = "notNull") private Currency _currency; /** * The GICS code. */ @PropertyDefinition private GICSCode _gicsCode; /** * The flag indicating whether the equity has preferred status or not. */ @PropertyDefinition private boolean _preferred; /** * Creates an instance. */ EquitySecurity() { //For builder super(SECURITY_TYPE); } /** * Creates an instance. * * @param exchange the exchange, not null * @param exchangeCode the exchange code, not null * @param companyName the company name, not null * @param currency the currency, not null */ public EquitySecurity(String exchange, String exchangeCode, String companyName, Currency currency) { super(SECURITY_TYPE); setExchange(exchange); setExchangeCode(exchangeCode); setCompanyName(companyName); setCurrency(currency); } //------------------------------------------------------------------------- @Override public final <T> T accept(FinancialSecurityVisitor<T> visitor) { return visitor.visitEquitySecurity(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code EquitySecurity}. * @return the meta-bean, not null */ public static EquitySecurity.Meta meta() { return EquitySecurity.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(EquitySecurity.Meta.INSTANCE); } @Override public EquitySecurity.Meta metaBean() { return EquitySecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the short name. * @return the value of the property */ public String getShortName() { return _shortName; } /** * Sets the short name. * @param shortName the new value of the property */ public void setShortName(String shortName) { this._shortName = shortName; } /** * Gets the the {@code shortName} property. * @return the property, not null */ public final Property<String> shortName() { return metaBean().shortName().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the exchange. * @return the value of the property, not null */ public String getExchange() { return _exchange; } /** * Sets the exchange. * @param exchange the new value of the property, not null */ public void setExchange(String exchange) { JodaBeanUtils.notNull(exchange, "exchange"); this._exchange = exchange; } /** * Gets the the {@code exchange} property. * @return the property, not null */ public final Property<String> exchange() { return metaBean().exchange().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the exchange code. * @return the value of the property, not null */ public String getExchangeCode() { return _exchangeCode; } /** * Sets the exchange code. * @param exchangeCode the new value of the property, not null */ public void setExchangeCode(String exchangeCode) { JodaBeanUtils.notNull(exchangeCode, "exchangeCode"); this._exchangeCode = exchangeCode; } /** * Gets the the {@code exchangeCode} property. * @return the property, not null */ public final Property<String> exchangeCode() { return metaBean().exchangeCode().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the company name. * @return the value of the property, not null */ public String getCompanyName() { return _companyName; } /** * Sets the company name. * @param companyName the new value of the property, not null */ public void setCompanyName(String companyName) { JodaBeanUtils.notNull(companyName, "companyName"); this._companyName = companyName; } /** * Gets the the {@code companyName} property. * @return the property, not null */ public final Property<String> companyName() { return metaBean().companyName().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 GICS code. * @return the value of the property */ public GICSCode getGicsCode() { return _gicsCode; } /** * Sets the GICS code. * @param gicsCode the new value of the property */ public void setGicsCode(GICSCode gicsCode) { this._gicsCode = gicsCode; } /** * Gets the the {@code gicsCode} property. * @return the property, not null */ public final Property<GICSCode> gicsCode() { return metaBean().gicsCode().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the flag indicating whether the equity has preferred status or not. * @return the value of the property */ public boolean isPreferred() { return _preferred; } /** * Sets the flag indicating whether the equity has preferred status or not. * @param preferred the new value of the property */ public void setPreferred(boolean preferred) { this._preferred = preferred; } /** * Gets the the {@code preferred} property. * @return the property, not null */ public final Property<Boolean> preferred() { return metaBean().preferred().createProperty(this); } //----------------------------------------------------------------------- @Override public EquitySecurity clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { EquitySecurity other = (EquitySecurity) obj; return JodaBeanUtils.equal(getShortName(), other.getShortName()) && JodaBeanUtils.equal(getExchange(), other.getExchange()) && JodaBeanUtils.equal(getExchangeCode(), other.getExchangeCode()) && JodaBeanUtils.equal(getCompanyName(), other.getCompanyName()) && JodaBeanUtils.equal(getCurrency(), other.getCurrency()) && JodaBeanUtils.equal(getGicsCode(), other.getGicsCode()) && (isPreferred() == other.isPreferred()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getShortName()); hash = hash * 31 + JodaBeanUtils.hashCode(getExchange()); hash = hash * 31 + JodaBeanUtils.hashCode(getExchangeCode()); hash = hash * 31 + JodaBeanUtils.hashCode(getCompanyName()); hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency()); hash = hash * 31 + JodaBeanUtils.hashCode(getGicsCode()); hash = hash * 31 + JodaBeanUtils.hashCode(isPreferred()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(256); buf.append("EquitySecurity{"); 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("shortName").append('=').append(JodaBeanUtils.toString(getShortName())).append(',').append(' '); buf.append("exchange").append('=').append(JodaBeanUtils.toString(getExchange())).append(',').append(' '); buf.append("exchangeCode").append('=').append(JodaBeanUtils.toString(getExchangeCode())).append(',').append(' '); buf.append("companyName").append('=').append(JodaBeanUtils.toString(getCompanyName())).append(',').append(' '); buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' '); buf.append("gicsCode").append('=').append(JodaBeanUtils.toString(getGicsCode())).append(',').append(' '); buf.append("preferred").append('=').append(JodaBeanUtils.toString(isPreferred())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code EquitySecurity}. */ 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 shortName} property. */ private final MetaProperty<String> _shortName = DirectMetaProperty.ofReadWrite( this, "shortName", EquitySecurity.class, String.class); /** * The meta-property for the {@code exchange} property. */ private final MetaProperty<String> _exchange = DirectMetaProperty.ofReadWrite( this, "exchange", EquitySecurity.class, String.class); /** * The meta-property for the {@code exchangeCode} property. */ private final MetaProperty<String> _exchangeCode = DirectMetaProperty.ofReadWrite( this, "exchangeCode", EquitySecurity.class, String.class); /** * The meta-property for the {@code companyName} property. */ private final MetaProperty<String> _companyName = DirectMetaProperty.ofReadWrite( this, "companyName", EquitySecurity.class, String.class); /** * The meta-property for the {@code currency} property. */ private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite( this, "currency", EquitySecurity.class, Currency.class); /** * The meta-property for the {@code gicsCode} property. */ private final MetaProperty<GICSCode> _gicsCode = DirectMetaProperty.ofReadWrite( this, "gicsCode", EquitySecurity.class, GICSCode.class); /** * The meta-property for the {@code preferred} property. */ private final MetaProperty<Boolean> _preferred = DirectMetaProperty.ofReadWrite( this, "preferred", EquitySecurity.class, Boolean.TYPE); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "shortName", "exchange", "exchangeCode", "companyName", "currency", "gicsCode", "preferred"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -2028219097: // shortName return _shortName; case 1989774883: // exchange return _exchange; case 1429202608: // exchangeCode return _exchangeCode; case -508582744: // companyName return _companyName; case 575402001: // currency return _currency; case 762040799: // gicsCode return _gicsCode; case -1294005119: // preferred return _preferred; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends EquitySecurity> builder() { return new DirectBeanBuilder<EquitySecurity>(new EquitySecurity()); } @Override public Class<? extends EquitySecurity> beanType() { return EquitySecurity.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code shortName} property. * @return the meta-property, not null */ public final MetaProperty<String> shortName() { return _shortName; } /** * The meta-property for the {@code exchange} property. * @return the meta-property, not null */ public final MetaProperty<String> exchange() { return _exchange; } /** * The meta-property for the {@code exchangeCode} property. * @return the meta-property, not null */ public final MetaProperty<String> exchangeCode() { return _exchangeCode; } /** * The meta-property for the {@code companyName} property. * @return the meta-property, not null */ public final MetaProperty<String> companyName() { return _companyName; } /** * 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 gicsCode} property. * @return the meta-property, not null */ public final MetaProperty<GICSCode> gicsCode() { return _gicsCode; } /** * The meta-property for the {@code preferred} property. * @return the meta-property, not null */ public final MetaProperty<Boolean> preferred() { return _preferred; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -2028219097: // shortName return ((EquitySecurity) bean).getShortName(); case 1989774883: // exchange return ((EquitySecurity) bean).getExchange(); case 1429202608: // exchangeCode return ((EquitySecurity) bean).getExchangeCode(); case -508582744: // companyName return ((EquitySecurity) bean).getCompanyName(); case 575402001: // currency return ((EquitySecurity) bean).getCurrency(); case 762040799: // gicsCode return ((EquitySecurity) bean).getGicsCode(); case -1294005119: // preferred return ((EquitySecurity) bean).isPreferred(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -2028219097: // shortName ((EquitySecurity) bean).setShortName((String) newValue); return; case 1989774883: // exchange ((EquitySecurity) bean).setExchange((String) newValue); return; case 1429202608: // exchangeCode ((EquitySecurity) bean).setExchangeCode((String) newValue); return; case -508582744: // companyName ((EquitySecurity) bean).setCompanyName((String) newValue); return; case 575402001: // currency ((EquitySecurity) bean).setCurrency((Currency) newValue); return; case 762040799: // gicsCode ((EquitySecurity) bean).setGicsCode((GICSCode) newValue); return; case -1294005119: // preferred ((EquitySecurity) bean).setPreferred((Boolean) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((EquitySecurity) bean)._exchange, "exchange"); JodaBeanUtils.notNull(((EquitySecurity) bean)._exchangeCode, "exchangeCode"); JodaBeanUtils.notNull(((EquitySecurity) bean)._companyName, "companyName"); JodaBeanUtils.notNull(((EquitySecurity) bean)._currency, "currency"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }