/**
* 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.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.opengamma.id.ExternalId;
import com.opengamma.master.security.ManageableSecurity;
/**
* An abstract base class for all index types.
*/
@BeanDefinition
public abstract class Index extends ManageableSecurity {
/** Serialization version */
private static final long serialVersionUID = 1L;
/**
* The index description.
*/
@PropertyDefinition
private String _description;
/**
* An optional linked IndexFamily
*/
@PropertyDefinition
private ExternalId _indexFamilyId;
/**
* For the builder.
* @param indexType The index type, not null
*/
public Index(final String indexType) {
super(indexType);
}
/**
* Creates an index without a description.
* @param indexType The index type, not null
* @param name The index name, not null
*/
public Index(final String indexType, final String name) {
super(indexType);
setName(name);
}
/**
* Creates an index.
* @param indexType The index type, not null
* @param name The index name, not null
* @param description The index description
*/
public Index(final String indexType, final String name, final String description) {
super(indexType);
setName(name);
setDescription(description);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code Index}.
* @return the meta-bean, not null
*/
public static Index.Meta meta() {
return Index.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(Index.Meta.INSTANCE);
}
@Override
public Index.Meta metaBean() {
return Index.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the index description.
* @return the value of the property
*/
public String getDescription() {
return _description;
}
/**
* Sets the index description.
* @param description the new value of the property
*/
public void setDescription(String description) {
this._description = description;
}
/**
* Gets the the {@code description} property.
* @return the property, not null
*/
public final Property<String> description() {
return metaBean().description().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets an optional linked IndexFamily
* @return the value of the property
*/
public ExternalId getIndexFamilyId() {
return _indexFamilyId;
}
/**
* Sets an optional linked IndexFamily
* @param indexFamilyId the new value of the property
*/
public void setIndexFamilyId(ExternalId indexFamilyId) {
this._indexFamilyId = indexFamilyId;
}
/**
* Gets the the {@code indexFamilyId} property.
* @return the property, not null
*/
public final Property<ExternalId> indexFamilyId() {
return metaBean().indexFamilyId().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
Index other = (Index) obj;
return JodaBeanUtils.equal(getDescription(), other.getDescription()) &&
JodaBeanUtils.equal(getIndexFamilyId(), other.getIndexFamilyId()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getDescription());
hash = hash * 31 + JodaBeanUtils.hashCode(getIndexFamilyId());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(96);
buf.append("Index{");
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("description").append('=').append(JodaBeanUtils.toString(getDescription())).append(',').append(' ');
buf.append("indexFamilyId").append('=').append(JodaBeanUtils.toString(getIndexFamilyId())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code Index}.
*/
public static class Meta extends ManageableSecurity.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code description} property.
*/
private final MetaProperty<String> _description = DirectMetaProperty.ofReadWrite(
this, "description", Index.class, String.class);
/**
* The meta-property for the {@code indexFamilyId} property.
*/
private final MetaProperty<ExternalId> _indexFamilyId = DirectMetaProperty.ofReadWrite(
this, "indexFamilyId", Index.class, ExternalId.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"description",
"indexFamilyId");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1724546052: // description
return _description;
case 1598011025: // indexFamilyId
return _indexFamilyId;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends Index> builder() {
throw new UnsupportedOperationException("Index is an abstract class");
}
@Override
public Class<? extends Index> beanType() {
return Index.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code description} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> description() {
return _description;
}
/**
* The meta-property for the {@code indexFamilyId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> indexFamilyId() {
return _indexFamilyId;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -1724546052: // description
return ((Index) bean).getDescription();
case 1598011025: // indexFamilyId
return ((Index) bean).getIndexFamilyId();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -1724546052: // description
((Index) bean).setDescription((String) newValue);
return;
case 1598011025: // indexFamilyId
((Index) bean).setIndexFamilyId((ExternalId) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}