/** * Copyright (C) 2014 - 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.id.ExternalId; import com.opengamma.master.security.SecurityDescription; /** * A class representing an exchange-traded fund. */ @BeanDefinition @SecurityDescription(type = ExchangeTradedFundSecurity.SECURITY_TYPE, description = "Etf") public class ExchangeTradedFundSecurity extends FinancialSecurity { /** Serialization version */ private static final long serialVersionUID = 1L; /** * The security type. */ public static final String SECURITY_TYPE = "ETF"; /** * The short name. */ @PropertyDefinition(validate = "notNull") private String _shortName; /** * The exchange description. */ @PropertyDefinition(validate = "notNull") private String _exchangeDescription; /** * The exchange code. */ @PropertyDefinition(validate = "notNull") private ExternalId _exchangeCode; /** * The underlying id. */ @PropertyDefinition(validate = "notNull") private ExternalId _underlyingId; /** * For the builder. */ /* package */ ExchangeTradedFundSecurity() { super(SECURITY_TYPE); } /** * @param shortName The short name, not null * @param exchangeDescription The exchange description, not null * @param exchangeCode The exchange code, not null * @param underlyingId The underlying id, not null */ public ExchangeTradedFundSecurity(final String shortName, final String exchangeDescription, final ExternalId exchangeCode, final ExternalId underlyingId) { super(SECURITY_TYPE); setShortName(shortName); setExchangeDescription(exchangeDescription); setExchangeCode(exchangeCode); setUnderlyingId(underlyingId); } @Override public <T> T accept(final FinancialSecurityVisitor<T> visitor) { return visitor.visitExchangeTradedFundSecurity(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code ExchangeTradedFundSecurity}. * @return the meta-bean, not null */ public static ExchangeTradedFundSecurity.Meta meta() { return ExchangeTradedFundSecurity.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(ExchangeTradedFundSecurity.Meta.INSTANCE); } @Override public ExchangeTradedFundSecurity.Meta metaBean() { return ExchangeTradedFundSecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the short name. * @return the value of the property, not null */ public String getShortName() { return _shortName; } /** * Sets the short name. * @param shortName the new value of the property, not null */ public void setShortName(String shortName) { JodaBeanUtils.notNull(shortName, "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 description. * @return the value of the property, not null */ public String getExchangeDescription() { return _exchangeDescription; } /** * Sets the exchange description. * @param exchangeDescription the new value of the property, not null */ public void setExchangeDescription(String exchangeDescription) { JodaBeanUtils.notNull(exchangeDescription, "exchangeDescription"); this._exchangeDescription = exchangeDescription; } /** * Gets the the {@code exchangeDescription} property. * @return the property, not null */ public final Property<String> exchangeDescription() { return metaBean().exchangeDescription().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the exchange code. * @return the value of the property, not null */ public ExternalId getExchangeCode() { return _exchangeCode; } /** * Sets the exchange code. * @param exchangeCode the new value of the property, not null */ public void setExchangeCode(ExternalId exchangeCode) { JodaBeanUtils.notNull(exchangeCode, "exchangeCode"); this._exchangeCode = exchangeCode; } /** * Gets the the {@code exchangeCode} property. * @return the property, not null */ public final Property<ExternalId> exchangeCode() { return metaBean().exchangeCode().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the underlying id. * @return the value of the property, not null */ public ExternalId getUnderlyingId() { return _underlyingId; } /** * Sets the underlying id. * @param underlyingId the new value of the property, not null */ public void setUnderlyingId(ExternalId underlyingId) { JodaBeanUtils.notNull(underlyingId, "underlyingId"); this._underlyingId = underlyingId; } /** * Gets the the {@code underlyingId} property. * @return the property, not null */ public final Property<ExternalId> underlyingId() { return metaBean().underlyingId().createProperty(this); } //----------------------------------------------------------------------- @Override public ExchangeTradedFundSecurity clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { ExchangeTradedFundSecurity other = (ExchangeTradedFundSecurity) obj; return JodaBeanUtils.equal(getShortName(), other.getShortName()) && JodaBeanUtils.equal(getExchangeDescription(), other.getExchangeDescription()) && JodaBeanUtils.equal(getExchangeCode(), other.getExchangeCode()) && JodaBeanUtils.equal(getUnderlyingId(), other.getUnderlyingId()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getShortName()); hash = hash * 31 + JodaBeanUtils.hashCode(getExchangeDescription()); hash = hash * 31 + JodaBeanUtils.hashCode(getExchangeCode()); hash = hash * 31 + JodaBeanUtils.hashCode(getUnderlyingId()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("ExchangeTradedFundSecurity{"); 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("exchangeDescription").append('=').append(JodaBeanUtils.toString(getExchangeDescription())).append(',').append(' '); buf.append("exchangeCode").append('=').append(JodaBeanUtils.toString(getExchangeCode())).append(',').append(' '); buf.append("underlyingId").append('=').append(JodaBeanUtils.toString(getUnderlyingId())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code ExchangeTradedFundSecurity}. */ 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", ExchangeTradedFundSecurity.class, String.class); /** * The meta-property for the {@code exchangeDescription} property. */ private final MetaProperty<String> _exchangeDescription = DirectMetaProperty.ofReadWrite( this, "exchangeDescription", ExchangeTradedFundSecurity.class, String.class); /** * The meta-property for the {@code exchangeCode} property. */ private final MetaProperty<ExternalId> _exchangeCode = DirectMetaProperty.ofReadWrite( this, "exchangeCode", ExchangeTradedFundSecurity.class, ExternalId.class); /** * The meta-property for the {@code underlyingId} property. */ private final MetaProperty<ExternalId> _underlyingId = DirectMetaProperty.ofReadWrite( this, "underlyingId", ExchangeTradedFundSecurity.class, ExternalId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "shortName", "exchangeDescription", "exchangeCode", "underlyingId"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -2028219097: // shortName return _shortName; case 862616025: // exchangeDescription return _exchangeDescription; case 1429202608: // exchangeCode return _exchangeCode; case -771625640: // underlyingId return _underlyingId; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends ExchangeTradedFundSecurity> builder() { return new DirectBeanBuilder<ExchangeTradedFundSecurity>(new ExchangeTradedFundSecurity()); } @Override public Class<? extends ExchangeTradedFundSecurity> beanType() { return ExchangeTradedFundSecurity.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 exchangeDescription} property. * @return the meta-property, not null */ public final MetaProperty<String> exchangeDescription() { return _exchangeDescription; } /** * The meta-property for the {@code exchangeCode} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> exchangeCode() { return _exchangeCode; } /** * The meta-property for the {@code underlyingId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> underlyingId() { return _underlyingId; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -2028219097: // shortName return ((ExchangeTradedFundSecurity) bean).getShortName(); case 862616025: // exchangeDescription return ((ExchangeTradedFundSecurity) bean).getExchangeDescription(); case 1429202608: // exchangeCode return ((ExchangeTradedFundSecurity) bean).getExchangeCode(); case -771625640: // underlyingId return ((ExchangeTradedFundSecurity) bean).getUnderlyingId(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -2028219097: // shortName ((ExchangeTradedFundSecurity) bean).setShortName((String) newValue); return; case 862616025: // exchangeDescription ((ExchangeTradedFundSecurity) bean).setExchangeDescription((String) newValue); return; case 1429202608: // exchangeCode ((ExchangeTradedFundSecurity) bean).setExchangeCode((ExternalId) newValue); return; case -771625640: // underlyingId ((ExchangeTradedFundSecurity) bean).setUnderlyingId((ExternalId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((ExchangeTradedFundSecurity) bean)._shortName, "shortName"); JodaBeanUtils.notNull(((ExchangeTradedFundSecurity) bean)._exchangeDescription, "exchangeDescription"); JodaBeanUtils.notNull(((ExchangeTradedFundSecurity) bean)._exchangeCode, "exchangeCode"); JodaBeanUtils.notNull(((ExchangeTradedFundSecurity) bean)._underlyingId, "underlyingId"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }