/** * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.security.swap; 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.id.UniqueId; /** * A notional that holds the security used as a notional, such as an index or equity. */ @BeanDefinition public class SecurityNotional extends Notional { /** Serialization version. */ private static final long serialVersionUID = 1L; /** * The identifier of the index or security. */ @PropertyDefinition(validate = "notNull") private UniqueId _notionalId; /** * Creates an instance. */ private SecurityNotional() { } /** * Creates an instance. * * @param notionalIdentifier the unique identifier, not null */ public SecurityNotional(UniqueId notionalIdentifier) { setNotionalId(notionalIdentifier); } //------------------------------------------------------------------------- @Override public <T> T accept(NotionalVisitor<T> visitor) { return visitor.visitSecurityNotional(this); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code SecurityNotional}. * @return the meta-bean, not null */ public static SecurityNotional.Meta meta() { return SecurityNotional.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(SecurityNotional.Meta.INSTANCE); } @Override public SecurityNotional.Meta metaBean() { return SecurityNotional.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the identifier of the index or security. * @return the value of the property, not null */ public UniqueId getNotionalId() { return _notionalId; } /** * Sets the identifier of the index or security. * @param notionalId the new value of the property, not null */ public void setNotionalId(UniqueId notionalId) { JodaBeanUtils.notNull(notionalId, "notionalId"); this._notionalId = notionalId; } /** * Gets the the {@code notionalId} property. * @return the property, not null */ public final Property<UniqueId> notionalId() { return metaBean().notionalId().createProperty(this); } //----------------------------------------------------------------------- @Override public SecurityNotional clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { SecurityNotional other = (SecurityNotional) obj; return JodaBeanUtils.equal(getNotionalId(), other.getNotionalId()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getNotionalId()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(64); buf.append("SecurityNotional{"); 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("notionalId").append('=').append(JodaBeanUtils.toString(getNotionalId())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code SecurityNotional}. */ public static class Meta extends Notional.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code notionalId} property. */ private final MetaProperty<UniqueId> _notionalId = DirectMetaProperty.ofReadWrite( this, "notionalId", SecurityNotional.class, UniqueId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "notionalId"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -917037957: // notionalId return _notionalId; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends SecurityNotional> builder() { return new DirectBeanBuilder<SecurityNotional>(new SecurityNotional()); } @Override public Class<? extends SecurityNotional> beanType() { return SecurityNotional.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code notionalId} property. * @return the meta-property, not null */ public final MetaProperty<UniqueId> notionalId() { return _notionalId; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -917037957: // notionalId return ((SecurityNotional) bean).getNotionalId(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -917037957: // notionalId ((SecurityNotional) bean).setNotionalId((UniqueId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((SecurityNotional) bean)._notionalId, "notionalId"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }