/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.analytics.parameters;
import java.io.Serializable;
import java.util.Map;
import java.util.SortedMap;
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.DirectBean;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
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;
import com.opengamma.id.MutableUniqueIdentifiable;
import com.opengamma.id.UniqueId;
import com.opengamma.id.UniqueIdentifiable;
import com.opengamma.util.money.Currency;
import com.opengamma.util.time.Tenor;
/**
* Config object that contains parameters for the Hull-White one factor model.
*/
@Config(description = "Hull-White one factor parameters", group = ConfigGroups.MISC)
@BeanDefinition
public class HullWhiteOneFactorParameters extends DirectBean implements Serializable, UniqueIdentifiable, MutableUniqueIdentifiable {
/** Serialization version. */
private static final long serialVersionUID = 1L;
/**
* The unique id of this configuration.
*/
@PropertyDefinition
private UniqueId _uniqueId;
/**
* The currency for which these parameters apply.
*/
@PropertyDefinition(validate = "notNull")
private Currency _currency;
/**
* The external id for the mean reversion parameter.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _meanReversionId;
/**
* The initial volatility id.
*/
@PropertyDefinition(validate = "notNull")
private ExternalId _initialVolatilityId;
/**
* A map of tenors to external ids that represent the volatility term structure.
*/
@PropertyDefinition(validate = "notNull")
private SortedMap<Tenor, ExternalId> _volatilityTermStructure;
/**
* For the builder.
*/
/* package */HullWhiteOneFactorParameters() {
super();
}
/**
* @param currency The currency, not null
* @param meanReversionId The mean reversion identifier, not null
* @param initialVolatilityId The initial volatility identifier, not null
* @param volatilityTermStructure The (tenor, identifier) map that represents the term structure, not null
*/
public HullWhiteOneFactorParameters(final Currency currency, final ExternalId meanReversionId, final ExternalId initialVolatilityId,
final SortedMap<Tenor, ExternalId> volatilityTermStructure) {
super();
setCurrency(currency);
setMeanReversionId(meanReversionId);
setInitialVolatilityId(initialVolatilityId);
setVolatilityTermStructure(volatilityTermStructure);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code HullWhiteOneFactorParameters}.
* @return the meta-bean, not null
*/
public static HullWhiteOneFactorParameters.Meta meta() {
return HullWhiteOneFactorParameters.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(HullWhiteOneFactorParameters.Meta.INSTANCE);
}
@Override
public HullWhiteOneFactorParameters.Meta metaBean() {
return HullWhiteOneFactorParameters.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the unique id of this configuration.
* @return the value of the property
*/
public UniqueId getUniqueId() {
return _uniqueId;
}
/**
* Sets the unique id of this configuration.
* @param uniqueId the new value of the property
*/
public void setUniqueId(UniqueId uniqueId) {
this._uniqueId = uniqueId;
}
/**
* Gets the the {@code uniqueId} property.
* @return the property, not null
*/
public final Property<UniqueId> uniqueId() {
return metaBean().uniqueId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the currency for which these parameters apply.
* @return the value of the property, not null
*/
public Currency getCurrency() {
return _currency;
}
/**
* Sets the currency for which these parameters apply.
* @param currency the new value of the property, not null
*/
public void setCurrency(Currency currency) {
JodaBeanUtils.notNull(currency, "currency");
this._currency = currency;
}
/**
* Gets the the {@code currency} property.
* @return the property, not null
*/
public final Property<Currency> currency() {
return metaBean().currency().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the external id for the mean reversion parameter.
* @return the value of the property, not null
*/
public ExternalId getMeanReversionId() {
return _meanReversionId;
}
/**
* Sets the external id for the mean reversion parameter.
* @param meanReversionId the new value of the property, not null
*/
public void setMeanReversionId(ExternalId meanReversionId) {
JodaBeanUtils.notNull(meanReversionId, "meanReversionId");
this._meanReversionId = meanReversionId;
}
/**
* Gets the the {@code meanReversionId} property.
* @return the property, not null
*/
public final Property<ExternalId> meanReversionId() {
return metaBean().meanReversionId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the initial volatility id.
* @return the value of the property, not null
*/
public ExternalId getInitialVolatilityId() {
return _initialVolatilityId;
}
/**
* Sets the initial volatility id.
* @param initialVolatilityId the new value of the property, not null
*/
public void setInitialVolatilityId(ExternalId initialVolatilityId) {
JodaBeanUtils.notNull(initialVolatilityId, "initialVolatilityId");
this._initialVolatilityId = initialVolatilityId;
}
/**
* Gets the the {@code initialVolatilityId} property.
* @return the property, not null
*/
public final Property<ExternalId> initialVolatilityId() {
return metaBean().initialVolatilityId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets a map of tenors to external ids that represent the volatility term structure.
* @return the value of the property, not null
*/
public SortedMap<Tenor, ExternalId> getVolatilityTermStructure() {
return _volatilityTermStructure;
}
/**
* Sets a map of tenors to external ids that represent the volatility term structure.
* @param volatilityTermStructure the new value of the property, not null
*/
public void setVolatilityTermStructure(SortedMap<Tenor, ExternalId> volatilityTermStructure) {
JodaBeanUtils.notNull(volatilityTermStructure, "volatilityTermStructure");
this._volatilityTermStructure = volatilityTermStructure;
}
/**
* Gets the the {@code volatilityTermStructure} property.
* @return the property, not null
*/
public final Property<SortedMap<Tenor, ExternalId>> volatilityTermStructure() {
return metaBean().volatilityTermStructure().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public HullWhiteOneFactorParameters clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
HullWhiteOneFactorParameters other = (HullWhiteOneFactorParameters) obj;
return JodaBeanUtils.equal(getUniqueId(), other.getUniqueId()) &&
JodaBeanUtils.equal(getCurrency(), other.getCurrency()) &&
JodaBeanUtils.equal(getMeanReversionId(), other.getMeanReversionId()) &&
JodaBeanUtils.equal(getInitialVolatilityId(), other.getInitialVolatilityId()) &&
JodaBeanUtils.equal(getVolatilityTermStructure(), other.getVolatilityTermStructure());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getUniqueId());
hash = hash * 31 + JodaBeanUtils.hashCode(getCurrency());
hash = hash * 31 + JodaBeanUtils.hashCode(getMeanReversionId());
hash = hash * 31 + JodaBeanUtils.hashCode(getInitialVolatilityId());
hash = hash * 31 + JodaBeanUtils.hashCode(getVolatilityTermStructure());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(192);
buf.append("HullWhiteOneFactorParameters{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
protected void toString(StringBuilder buf) {
buf.append("uniqueId").append('=').append(JodaBeanUtils.toString(getUniqueId())).append(',').append(' ');
buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())).append(',').append(' ');
buf.append("meanReversionId").append('=').append(JodaBeanUtils.toString(getMeanReversionId())).append(',').append(' ');
buf.append("initialVolatilityId").append('=').append(JodaBeanUtils.toString(getInitialVolatilityId())).append(',').append(' ');
buf.append("volatilityTermStructure").append('=').append(JodaBeanUtils.toString(getVolatilityTermStructure())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code HullWhiteOneFactorParameters}.
*/
public static class Meta extends DirectMetaBean {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code uniqueId} property.
*/
private final MetaProperty<UniqueId> _uniqueId = DirectMetaProperty.ofReadWrite(
this, "uniqueId", HullWhiteOneFactorParameters.class, UniqueId.class);
/**
* The meta-property for the {@code currency} property.
*/
private final MetaProperty<Currency> _currency = DirectMetaProperty.ofReadWrite(
this, "currency", HullWhiteOneFactorParameters.class, Currency.class);
/**
* The meta-property for the {@code meanReversionId} property.
*/
private final MetaProperty<ExternalId> _meanReversionId = DirectMetaProperty.ofReadWrite(
this, "meanReversionId", HullWhiteOneFactorParameters.class, ExternalId.class);
/**
* The meta-property for the {@code initialVolatilityId} property.
*/
private final MetaProperty<ExternalId> _initialVolatilityId = DirectMetaProperty.ofReadWrite(
this, "initialVolatilityId", HullWhiteOneFactorParameters.class, ExternalId.class);
/**
* The meta-property for the {@code volatilityTermStructure} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<SortedMap<Tenor, ExternalId>> _volatilityTermStructure = DirectMetaProperty.ofReadWrite(
this, "volatilityTermStructure", HullWhiteOneFactorParameters.class, (Class) SortedMap.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"uniqueId",
"currency",
"meanReversionId",
"initialVolatilityId",
"volatilityTermStructure");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -294460212: // uniqueId
return _uniqueId;
case 575402001: // currency
return _currency;
case -884768197: // meanReversionId
return _meanReversionId;
case 287677828: // initialVolatilityId
return _initialVolatilityId;
case -1883573694: // volatilityTermStructure
return _volatilityTermStructure;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends HullWhiteOneFactorParameters> builder() {
return new DirectBeanBuilder<HullWhiteOneFactorParameters>(new HullWhiteOneFactorParameters());
}
@Override
public Class<? extends HullWhiteOneFactorParameters> beanType() {
return HullWhiteOneFactorParameters.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code uniqueId} property.
* @return the meta-property, not null
*/
public final MetaProperty<UniqueId> uniqueId() {
return _uniqueId;
}
/**
* The meta-property for the {@code currency} property.
* @return the meta-property, not null
*/
public final MetaProperty<Currency> currency() {
return _currency;
}
/**
* The meta-property for the {@code meanReversionId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> meanReversionId() {
return _meanReversionId;
}
/**
* The meta-property for the {@code initialVolatilityId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ExternalId> initialVolatilityId() {
return _initialVolatilityId;
}
/**
* The meta-property for the {@code volatilityTermStructure} property.
* @return the meta-property, not null
*/
public final MetaProperty<SortedMap<Tenor, ExternalId>> volatilityTermStructure() {
return _volatilityTermStructure;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -294460212: // uniqueId
return ((HullWhiteOneFactorParameters) bean).getUniqueId();
case 575402001: // currency
return ((HullWhiteOneFactorParameters) bean).getCurrency();
case -884768197: // meanReversionId
return ((HullWhiteOneFactorParameters) bean).getMeanReversionId();
case 287677828: // initialVolatilityId
return ((HullWhiteOneFactorParameters) bean).getInitialVolatilityId();
case -1883573694: // volatilityTermStructure
return ((HullWhiteOneFactorParameters) bean).getVolatilityTermStructure();
}
return super.propertyGet(bean, propertyName, quiet);
}
@SuppressWarnings("unchecked")
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -294460212: // uniqueId
((HullWhiteOneFactorParameters) bean).setUniqueId((UniqueId) newValue);
return;
case 575402001: // currency
((HullWhiteOneFactorParameters) bean).setCurrency((Currency) newValue);
return;
case -884768197: // meanReversionId
((HullWhiteOneFactorParameters) bean).setMeanReversionId((ExternalId) newValue);
return;
case 287677828: // initialVolatilityId
((HullWhiteOneFactorParameters) bean).setInitialVolatilityId((ExternalId) newValue);
return;
case -1883573694: // volatilityTermStructure
((HullWhiteOneFactorParameters) bean).setVolatilityTermStructure((SortedMap<Tenor, ExternalId>) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((HullWhiteOneFactorParameters) bean)._currency, "currency");
JodaBeanUtils.notNull(((HullWhiteOneFactorParameters) bean)._meanReversionId, "meanReversionId");
JodaBeanUtils.notNull(((HullWhiteOneFactorParameters) bean)._initialVolatilityId, "initialVolatilityId");
JodaBeanUtils.notNull(((HullWhiteOneFactorParameters) bean)._volatilityTermStructure, "volatilityTermStructure");
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}