/**
* 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.master.security.SecurityDescription;
/**
* Class representing an overnight interest rate index.
*/
@BeanDefinition
@SecurityDescription(type = PriceIndex.INDEX_TYPE, description = "Price index")
public class PriceIndex extends Index {
/** Serialization version */
private static final long serialVersionUID = 1L;
/**
* The index type.
*/
public static final String INDEX_TYPE = "PRICE_INDEX";
/**
* The external id of the convention.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _conventionId;
/**
* For the builder.
*/
public PriceIndex() {
super(INDEX_TYPE);
}
/**
* @param name The index name, not null
* @param conventionId The convention id, not null
*/
public PriceIndex(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 PriceIndex(final String name, final String description, final ExternalId conventionId) {
super(INDEX_TYPE, name, description);
setConventionId(conventionId);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code PriceIndex}.
* @return the meta-bean, not null
*/
public static PriceIndex.Meta meta() {
return PriceIndex.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(PriceIndex.Meta.INSTANCE);
}
@Override
public PriceIndex.Meta metaBean() {
return PriceIndex.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 PriceIndex clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
PriceIndex other = (PriceIndex) 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("PriceIndex{");
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 PriceIndex}.
*/
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", PriceIndex.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 PriceIndex> builder() {
return new DirectBeanBuilder<PriceIndex>(new PriceIndex());
}
@Override
public Class<? extends PriceIndex> beanType() {
return PriceIndex.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 ((PriceIndex) 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
((PriceIndex) bean).setConventionId((ExternalId) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((PriceIndex) bean)._conventionId, "conventionId");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}