/** * 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 spread curves. There are two forms supported: * <ul> * <li> Two curves and the operation to perform on these curves. * <li> One curve, a constant spread value with units, and the operation. * </ul> * <p> * Note that the operation might not be commutative, so the order of the inputs is important. */ @BeanDefinition @Config(description = "Spread curve definition", group = ConfigGroups.CURVES) public class ConstantSpreadCurveDefinition extends AbstractCurveDefinition { /** Serialization version */ private static final long serialVersionUID = 1L; /** * The curve. */ @PropertyDefinition(validate = "notNull") private String _curve; /** * The spread value. */ @PropertyDefinition private Double _spreadValue; /** * The id of the spread. */ @PropertyDefinition private ExternalId _spreadId; /** * The value requirement name. */ @PropertyDefinition private String _valueRequirementName; /** * The properties. */ @PropertyDefinition private Map<String, String> _properties; /** * The operation name. */ @PropertyDefinition(validate = "notNull") private String _operationName; /** * For the builder. */ ConstantSpreadCurveDefinition() { super(); } /** * Constructor that creates a curve definition with the supplied spread. * @param name The curve definition name, not null * @param curve The curve, not null * @param spreadValue The spread value * @param operationName The operation name, not null */ public ConstantSpreadCurveDefinition(final String name, final String curve, final double spreadValue, final String operationName) { super(name); setCurve(curve); setSpreadValue(spreadValue); setSpreadId(null); setValueRequirementName(null); setProperties(null); setOperationName(operationName); } /** * Constructor that creates a curve definition with a * @param name The curve definition name, not null * @param curve The curve, not null * @param spreadId The spread, not null * @param operationName The operation name, not null */ public ConstantSpreadCurveDefinition(final String name, final String curve, final ExternalId spreadId, final String operationName) { super(name); setCurve(curve); setSpreadValue(null); setSpreadId(spreadId); setValueRequirementName(null); setProperties(null); setOperationName(operationName); } /** * @param name The curve definition name, not null * @param curve The curve, not null * @param valueRequirementName The value requirement name, not null * @param valueProperties The value properties, not null * @param operationName The operation name, not null */ public ConstantSpreadCurveDefinition(final String name, final String curve, final String valueRequirementName, final Map<String, String> valueProperties, final String operationName) { super(name); JodaBeanUtils.notNull(valueRequirementName, "valueRequirementName"); JodaBeanUtils.notNull(valueProperties, "valueProperties"); setCurve(curve); setSpreadValue(null); setSpreadId(null); setValueRequirementName(valueRequirementName); setProperties(valueProperties); setOperationName(operationName); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code ConstantSpreadCurveDefinition}. * @return the meta-bean, not null */ public static ConstantSpreadCurveDefinition.Meta meta() { return ConstantSpreadCurveDefinition.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(ConstantSpreadCurveDefinition.Meta.INSTANCE); } @Override public ConstantSpreadCurveDefinition.Meta metaBean() { return ConstantSpreadCurveDefinition.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the curve. * @return the value of the property, not null */ public String getCurve() { return _curve; } /** * Sets the curve. * @param curve the new value of the property, not null */ public void setCurve(String curve) { JodaBeanUtils.notNull(curve, "curve"); this._curve = curve; } /** * Gets the the {@code curve} property. * @return the property, not null */ public final Property<String> curve() { return metaBean().curve().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the spread value. * @return the value of the property */ public Double getSpreadValue() { return _spreadValue; } /** * Sets the spread value. * @param spreadValue the new value of the property */ public void setSpreadValue(Double spreadValue) { this._spreadValue = spreadValue; } /** * Gets the the {@code spreadValue} property. * @return the property, not null */ public final Property<Double> spreadValue() { return metaBean().spreadValue().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the id of the spread. * @return the value of the property */ public ExternalId getSpreadId() { return _spreadId; } /** * Sets the id of the spread. * @param spreadId the new value of the property */ public void setSpreadId(ExternalId spreadId) { this._spreadId = spreadId; } /** * Gets the the {@code spreadId} property. * @return the property, not null */ public final Property<ExternalId> spreadId() { return metaBean().spreadId().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the value requirement name. * @return the value of the property */ public String getValueRequirementName() { return _valueRequirementName; } /** * Sets the value requirement name. * @param valueRequirementName the new value of the property */ public void setValueRequirementName(String valueRequirementName) { this._valueRequirementName = valueRequirementName; } /** * Gets the the {@code valueRequirementName} property. * @return the property, not null */ public final Property<String> valueRequirementName() { return metaBean().valueRequirementName().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the properties. * @return the value of the property */ public Map<String, String> getProperties() { return _properties; } /** * Sets the properties. * @param properties the new value of the property */ public void setProperties(Map<String, String> properties) { this._properties = properties; } /** * Gets the the {@code properties} property. * @return the property, not null */ public final Property<Map<String, String>> properties() { return metaBean().properties().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the operation name. * @return the value of the property, not null */ public String getOperationName() { return _operationName; } /** * Sets the operation name. * @param operationName the new value of the property, not null */ public void setOperationName(String operationName) { JodaBeanUtils.notNull(operationName, "operationName"); this._operationName = operationName; } /** * Gets the the {@code operationName} property. * @return the property, not null */ public final Property<String> operationName() { return metaBean().operationName().createProperty(this); } //----------------------------------------------------------------------- @Override public ConstantSpreadCurveDefinition clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { ConstantSpreadCurveDefinition other = (ConstantSpreadCurveDefinition) obj; return JodaBeanUtils.equal(getCurve(), other.getCurve()) && JodaBeanUtils.equal(getSpreadValue(), other.getSpreadValue()) && JodaBeanUtils.equal(getSpreadId(), other.getSpreadId()) && JodaBeanUtils.equal(getValueRequirementName(), other.getValueRequirementName()) && JodaBeanUtils.equal(getProperties(), other.getProperties()) && JodaBeanUtils.equal(getOperationName(), other.getOperationName()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getCurve()); hash = hash * 31 + JodaBeanUtils.hashCode(getSpreadValue()); hash = hash * 31 + JodaBeanUtils.hashCode(getSpreadId()); hash = hash * 31 + JodaBeanUtils.hashCode(getValueRequirementName()); hash = hash * 31 + JodaBeanUtils.hashCode(getProperties()); hash = hash * 31 + JodaBeanUtils.hashCode(getOperationName()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(224); buf.append("ConstantSpreadCurveDefinition{"); 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("curve").append('=').append(JodaBeanUtils.toString(getCurve())).append(',').append(' '); buf.append("spreadValue").append('=').append(JodaBeanUtils.toString(getSpreadValue())).append(',').append(' '); buf.append("spreadId").append('=').append(JodaBeanUtils.toString(getSpreadId())).append(',').append(' '); buf.append("valueRequirementName").append('=').append(JodaBeanUtils.toString(getValueRequirementName())).append(',').append(' '); buf.append("properties").append('=').append(JodaBeanUtils.toString(getProperties())).append(',').append(' '); buf.append("operationName").append('=').append(JodaBeanUtils.toString(getOperationName())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code ConstantSpreadCurveDefinition}. */ 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 curve} property. */ private final MetaProperty<String> _curve = DirectMetaProperty.ofReadWrite( this, "curve", ConstantSpreadCurveDefinition.class, String.class); /** * The meta-property for the {@code spreadValue} property. */ private final MetaProperty<Double> _spreadValue = DirectMetaProperty.ofReadWrite( this, "spreadValue", ConstantSpreadCurveDefinition.class, Double.class); /** * The meta-property for the {@code spreadId} property. */ private final MetaProperty<ExternalId> _spreadId = DirectMetaProperty.ofReadWrite( this, "spreadId", ConstantSpreadCurveDefinition.class, ExternalId.class); /** * The meta-property for the {@code valueRequirementName} property. */ private final MetaProperty<String> _valueRequirementName = DirectMetaProperty.ofReadWrite( this, "valueRequirementName", ConstantSpreadCurveDefinition.class, String.class); /** * The meta-property for the {@code properties} property. */ @SuppressWarnings({"unchecked", "rawtypes" }) private final MetaProperty<Map<String, String>> _properties = DirectMetaProperty.ofReadWrite( this, "properties", ConstantSpreadCurveDefinition.class, (Class) Map.class); /** * The meta-property for the {@code operationName} property. */ private final MetaProperty<String> _operationName = DirectMetaProperty.ofReadWrite( this, "operationName", ConstantSpreadCurveDefinition.class, String.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "curve", "spreadValue", "spreadId", "valueRequirementName", "properties", "operationName"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 95027439: // curve return _curve; case 2147000254: // spreadValue return _spreadValue; case -1759090194: // spreadId return _spreadId; case 1646585789: // valueRequirementName return _valueRequirementName; case -926053069: // properties return _properties; case 91797650: // operationName return _operationName; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends ConstantSpreadCurveDefinition> builder() { return new DirectBeanBuilder<ConstantSpreadCurveDefinition>(new ConstantSpreadCurveDefinition()); } @Override public Class<? extends ConstantSpreadCurveDefinition> beanType() { return ConstantSpreadCurveDefinition.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code curve} property. * @return the meta-property, not null */ public final MetaProperty<String> curve() { return _curve; } /** * The meta-property for the {@code spreadValue} property. * @return the meta-property, not null */ public final MetaProperty<Double> spreadValue() { return _spreadValue; } /** * The meta-property for the {@code spreadId} property. * @return the meta-property, not null */ public final MetaProperty<ExternalId> spreadId() { return _spreadId; } /** * The meta-property for the {@code valueRequirementName} property. * @return the meta-property, not null */ public final MetaProperty<String> valueRequirementName() { return _valueRequirementName; } /** * The meta-property for the {@code properties} property. * @return the meta-property, not null */ public final MetaProperty<Map<String, String>> properties() { return _properties; } /** * The meta-property for the {@code operationName} property. * @return the meta-property, not null */ public final MetaProperty<String> operationName() { return _operationName; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 95027439: // curve return ((ConstantSpreadCurveDefinition) bean).getCurve(); case 2147000254: // spreadValue return ((ConstantSpreadCurveDefinition) bean).getSpreadValue(); case -1759090194: // spreadId return ((ConstantSpreadCurveDefinition) bean).getSpreadId(); case 1646585789: // valueRequirementName return ((ConstantSpreadCurveDefinition) bean).getValueRequirementName(); case -926053069: // properties return ((ConstantSpreadCurveDefinition) bean).getProperties(); case 91797650: // operationName return ((ConstantSpreadCurveDefinition) bean).getOperationName(); } return super.propertyGet(bean, propertyName, quiet); } @SuppressWarnings("unchecked") @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 95027439: // curve ((ConstantSpreadCurveDefinition) bean).setCurve((String) newValue); return; case 2147000254: // spreadValue ((ConstantSpreadCurveDefinition) bean).setSpreadValue((Double) newValue); return; case -1759090194: // spreadId ((ConstantSpreadCurveDefinition) bean).setSpreadId((ExternalId) newValue); return; case 1646585789: // valueRequirementName ((ConstantSpreadCurveDefinition) bean).setValueRequirementName((String) newValue); return; case -926053069: // properties ((ConstantSpreadCurveDefinition) bean).setProperties((Map<String, String>) newValue); return; case 91797650: // operationName ((ConstantSpreadCurveDefinition) bean).setOperationName((String) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((ConstantSpreadCurveDefinition) bean)._curve, "curve"); JodaBeanUtils.notNull(((ConstantSpreadCurveDefinition) bean)._operationName, "operationName"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }