/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.analytics.curve;
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.core.config.Config;
import com.opengamma.core.config.ConfigGroups;
import com.opengamma.id.ExternalId;
/**
* Definition for constant curves. It contains the curve name and the
* {@link ExternalId} of the constant value.
*/
@BeanDefinition
@Config(description = "Constant curve definition", group = ConfigGroups.CURVES)
public class ConstantCurveDefinition extends AbstractCurveDefinition {
/** Serialization version */
private static final long serialVersionUID = 1L;
/**
* The external id of the constant value.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _externalId;
/**
* The data field of the constant value.
*/
@PropertyDefinition
private String _dataField;
/**
* For the builder.
*/
/* package */ ConstantCurveDefinition() {
super();
}
/**
* @param name The curve definition name, not null
* @param externalId The external id of the constant value, not null
*/
public ConstantCurveDefinition(final String name, final ExternalId externalId) {
super(name);
setExternalId(externalId);
}
/**
* @param name The curve definition name, not null
* @param externalId The external id of the constant value, not null
* @param dataField The data field of the constant value
*/
public ConstantCurveDefinition(final String name, final ExternalId externalId, final String dataField) {
super(name);
setExternalId(externalId);
setDataField(dataField);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code ConstantCurveDefinition}.
* @return the meta-bean, not null
*/
public static ConstantCurveDefinition.Meta meta() {
return ConstantCurveDefinition.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(ConstantCurveDefinition.Meta.INSTANCE);
}
@Override
public ConstantCurveDefinition.Meta metaBean() {
return ConstantCurveDefinition.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the external id of the constant value.
* @return the value of the property, not null
*/
public ExternalId getExternalId() {
return _externalId;
}
/**
* Sets the external id of the constant value.
* @param externalId the new value of the property, not null
*/
public void setExternalId(ExternalId externalId) {
JodaBeanUtils.notNull(externalId, "externalId");
this._externalId = externalId;
}
/**
* Gets the the {@code externalId} property.
* @return the property, not null
*/
public final Property<ExternalId> externalId() {
return metaBean().externalId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the data field of the constant value.
* @return the value of the property
*/
public String getDataField() {
return _dataField;
}
/**
* Sets the data field of the constant value.
* @param dataField the new value of the property
*/
public void setDataField(String dataField) {
this._dataField = dataField;
}
/**
* Gets the the {@code dataField} property.
* @return the property, not null
*/
public final Property<String> dataField() {
return metaBean().dataField().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public ConstantCurveDefinition clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
ConstantCurveDefinition other = (ConstantCurveDefinition) obj;
return JodaBeanUtils.equal(getExternalId(), other.getExternalId()) &&
JodaBeanUtils.equal(getDataField(), other.getDataField()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getExternalId());
hash = hash * 31 + JodaBeanUtils.hashCode(getDataField());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(96);
buf.append("ConstantCurveDefinition{");
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("externalId").append('=').append(JodaBeanUtils.toString(getExternalId())).append(',').append(' ');
buf.append("dataField").append('=').append(JodaBeanUtils.toString(getDataField())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code ConstantCurveDefinition}.
*/
public static class Meta extends AbstractCurveDefinition.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code externalId} property.
*/
private final MetaProperty<ExternalId> _externalId = DirectMetaProperty.ofReadWrite(
this, "externalId", ConstantCurveDefinition.class, ExternalId.class);
/**
* The meta-property for the {@code dataField} property.
*/
private final MetaProperty<String> _dataField = DirectMetaProperty.ofReadWrite(
this, "dataField", ConstantCurveDefinition.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"externalId",
"dataField");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1699764666: // externalId
return _externalId;
case -386794640: // dataField
return _dataField;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends ConstantCurveDefinition> builder() {
return new DirectBeanBuilder<ConstantCurveDefinition>(new ConstantCurveDefinition());
}
@Override
public Class<? extends ConstantCurveDefinition> beanType() {
return ConstantCurveDefinition.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code externalId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> externalId() {
return _externalId;
}
/**
* The meta-property for the {@code dataField} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> dataField() {
return _dataField;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -1699764666: // externalId
return ((ConstantCurveDefinition) bean).getExternalId();
case -386794640: // dataField
return ((ConstantCurveDefinition) bean).getDataField();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -1699764666: // externalId
((ConstantCurveDefinition) bean).setExternalId((ExternalId) newValue);
return;
case -386794640: // dataField
((ConstantCurveDefinition) bean).setDataField((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((ConstantCurveDefinition) bean)._externalId, "externalId");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}