/**
* Copyright (C) 2014 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.security.index;
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.ExternalId;
import com.opengamma.id.ExternalIdBundle;
import com.opengamma.master.security.SecurityDescription;
/**
* Class representing an overnight interest rate index.
*/
@BeanDefinition
@SecurityDescription(type = OvernightIndex.INDEX_TYPE, description = "Overnight index")
public class OvernightIndex extends Index {
/** Serialization version */
private static final long serialVersionUID = 1L;
/**
* The index type.
*/
public static final String INDEX_TYPE = "OVERNIGHT_INDEX";
/**
* The external id of the convention.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _conventionId;
/**
* For the builder.
*/
public OvernightIndex() {
super(INDEX_TYPE);
}
/**
* @param name The index name, not null
* @param conventionId The convention id, not null
*/
public OvernightIndex(final String name, final ExternalId conventionId) {
super(INDEX_TYPE, name);
setConventionId(conventionId);
}
/**
* @param name The index name, not null
* @param description The description name, not null
* @param conventionId The convention id, not null
*/
public OvernightIndex(final String name, final String description, final ExternalId conventionId) {
super(INDEX_TYPE, name, description);
setConventionId(conventionId);
}
/**
* @param name The index name, not null
* @param description The description name, not null
* @param conventionId The convention id, not null
* @param idBundle The external id bundle for this security, not null
*/
public OvernightIndex(final String name, final String description, final ExternalId conventionId, ExternalIdBundle idBundle) {
super(INDEX_TYPE, name, description);
setConventionId(conventionId);
setExternalIdBundle(idBundle);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code OvernightIndex}.
* @return the meta-bean, not null
*/
public static OvernightIndex.Meta meta() {
return OvernightIndex.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(OvernightIndex.Meta.INSTANCE);
}
@Override
public OvernightIndex.Meta metaBean() {
return OvernightIndex.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the external id of the convention.
* @return the value of the property, not null
*/
public ExternalId getConventionId() {
return _conventionId;
}
/**
* Sets the external id of the convention.
* @param conventionId the new value of the property, not null
*/
public void setConventionId(ExternalId conventionId) {
JodaBeanUtils.notNull(conventionId, "conventionId");
this._conventionId = conventionId;
}
/**
* Gets the the {@code conventionId} property.
* @return the property, not null
*/
public final Property<ExternalId> conventionId() {
return metaBean().conventionId().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public OvernightIndex clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
OvernightIndex other = (OvernightIndex) obj;
return JodaBeanUtils.equal(getConventionId(), other.getConventionId()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getConventionId());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(64);
buf.append("OvernightIndex{");
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("conventionId").append('=').append(JodaBeanUtils.toString(getConventionId())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code OvernightIndex}.
*/
public static class Meta extends Index.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code conventionId} property.
*/
private final MetaProperty<ExternalId> _conventionId = DirectMetaProperty.ofReadWrite(
this, "conventionId", OvernightIndex.class, ExternalId.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"conventionId");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 1520979052: // conventionId
return _conventionId;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends OvernightIndex> builder() {
return new DirectBeanBuilder<OvernightIndex>(new OvernightIndex());
}
@Override
public Class<? extends OvernightIndex> beanType() {
return OvernightIndex.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code conventionId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> conventionId() {
return _conventionId;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 1520979052: // conventionId
return ((OvernightIndex) bean).getConventionId();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 1520979052: // conventionId
((OvernightIndex) bean).setConventionId((ExternalId) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((OvernightIndex) bean)._conventionId, "conventionId");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}