/**
* Copyright (C) 2014 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.sesame;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import org.joda.beans.Bean;
import org.joda.beans.BeanDefinition;
import org.joda.beans.ImmutableBean;
import org.joda.beans.ImmutableConstructor;
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.DirectFieldsBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.google.common.collect.ImmutableList;
import com.opengamma.analytics.financial.interestrate.InstrumentDerivative;
import com.opengamma.util.ArgumentChecker;
import com.opengamma.util.time.Tenor;
/**
* Holds the data for an implied deposit curve.
*/
@BeanDefinition
public final class ImpliedDepositCurveData implements ImmutableBean {
/**
* The tenors for the implied curve data.
*/
@PropertyDefinition(validate = "notNull")
private final List<Tenor> _tenors;
/**
* The par rates corresponding to the tenors.
*/
@PropertyDefinition(validate = "notNull")
private final List<Double> _parRates;
/**
* The cash nodes corresponding to the tenors.
*/
@PropertyDefinition(validate = "notNull")
private final List<InstrumentDerivative> _cashNodes;
@ImmutableConstructor
public ImpliedDepositCurveData(List<Tenor> tenors, List<Double> parRates, List<InstrumentDerivative> cashNodes) {
_tenors = ImmutableList.copyOf(ArgumentChecker.notNull(tenors, "tenors"));
_parRates = ImmutableList.copyOf(ArgumentChecker.notNull(parRates, "parRates"));
_cashNodes = ImmutableList.copyOf(ArgumentChecker.notNull(cashNodes, "cashNodes"));
ArgumentChecker.isTrue(_tenors.size() == _parRates.size(),
"There are {} tenors but {} par rates, they should be the same", _tenors.size(), _parRates.size());
ArgumentChecker.isTrue(_tenors.size() == _cashNodes.size(),
"There are {} tenors but {} cash nodes, they should be the same", _tenors.size(), _cashNodes.size());
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code ImpliedDepositCurveData}.
* @return the meta-bean, not null
*/
public static ImpliedDepositCurveData.Meta meta() {
return ImpliedDepositCurveData.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(ImpliedDepositCurveData.Meta.INSTANCE);
}
/**
* Returns a builder used to create an instance of the bean.
* @return the builder, not null
*/
public static ImpliedDepositCurveData.Builder builder() {
return new ImpliedDepositCurveData.Builder();
}
@Override
public ImpliedDepositCurveData.Meta metaBean() {
return ImpliedDepositCurveData.Meta.INSTANCE;
}
@Override
public <R> Property<R> property(String propertyName) {
return metaBean().<R>metaProperty(propertyName).createProperty(this);
}
@Override
public Set<String> propertyNames() {
return metaBean().metaPropertyMap().keySet();
}
//-----------------------------------------------------------------------
/**
* Gets the tenors for the implied curve data.
* @return the value of the property, not null
*/
public List<Tenor> getTenors() {
return _tenors;
}
//-----------------------------------------------------------------------
/**
* Gets the par rates corresponding to the tenors.
* @return the value of the property, not null
*/
public List<Double> getParRates() {
return _parRates;
}
//-----------------------------------------------------------------------
/**
* Gets the cash nodes corresponding to the tenors.
* @return the value of the property, not null
*/
public List<InstrumentDerivative> getCashNodes() {
return _cashNodes;
}
//-----------------------------------------------------------------------
/**
* Returns a builder that allows this bean to be mutated.
* @return the mutable builder, not null
*/
public Builder toBuilder() {
return new Builder(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
ImpliedDepositCurveData other = (ImpliedDepositCurveData) obj;
return JodaBeanUtils.equal(getTenors(), other.getTenors()) &&
JodaBeanUtils.equal(getParRates(), other.getParRates()) &&
JodaBeanUtils.equal(getCashNodes(), other.getCashNodes());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getTenors());
hash = hash * 31 + JodaBeanUtils.hashCode(getParRates());
hash = hash * 31 + JodaBeanUtils.hashCode(getCashNodes());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(128);
buf.append("ImpliedDepositCurveData{");
buf.append("tenors").append('=').append(getTenors()).append(',').append(' ');
buf.append("parRates").append('=').append(getParRates()).append(',').append(' ');
buf.append("cashNodes").append('=').append(JodaBeanUtils.toString(getCashNodes()));
buf.append('}');
return buf.toString();
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code ImpliedDepositCurveData}.
*/
public static final class Meta extends DirectMetaBean {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code tenors} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<List<Tenor>> _tenors = DirectMetaProperty.ofImmutable(
this, "tenors", ImpliedDepositCurveData.class, (Class) List.class);
/**
* The meta-property for the {@code parRates} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<List<Double>> _parRates = DirectMetaProperty.ofImmutable(
this, "parRates", ImpliedDepositCurveData.class, (Class) List.class);
/**
* The meta-property for the {@code cashNodes} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<List<InstrumentDerivative>> _cashNodes = DirectMetaProperty.ofImmutable(
this, "cashNodes", ImpliedDepositCurveData.class, (Class) List.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"tenors",
"parRates",
"cashNodes");
/**
* Restricted constructor.
*/
private Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -877322829: // tenors
return _tenors;
case 1157229426: // parRates
return _parRates;
case 741125950: // cashNodes
return _cashNodes;
}
return super.metaPropertyGet(propertyName);
}
@Override
public ImpliedDepositCurveData.Builder builder() {
return new ImpliedDepositCurveData.Builder();
}
@Override
public Class<? extends ImpliedDepositCurveData> beanType() {
return ImpliedDepositCurveData.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code tenors} property.
* @return the meta-property, not null
*/
public MetaProperty<List<Tenor>> tenors() {
return _tenors;
}
/**
* The meta-property for the {@code parRates} property.
* @return the meta-property, not null
*/
public MetaProperty<List<Double>> parRates() {
return _parRates;
}
/**
* The meta-property for the {@code cashNodes} property.
* @return the meta-property, not null
*/
public MetaProperty<List<InstrumentDerivative>> cashNodes() {
return _cashNodes;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -877322829: // tenors
return ((ImpliedDepositCurveData) bean).getTenors();
case 1157229426: // parRates
return ((ImpliedDepositCurveData) bean).getParRates();
case 741125950: // cashNodes
return ((ImpliedDepositCurveData) bean).getCashNodes();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
metaProperty(propertyName);
if (quiet) {
return;
}
throw new UnsupportedOperationException("Property cannot be written: " + propertyName);
}
}
//-----------------------------------------------------------------------
/**
* The bean-builder for {@code ImpliedDepositCurveData}.
*/
public static final class Builder extends DirectFieldsBeanBuilder<ImpliedDepositCurveData> {
private List<Tenor> _tenors = new ArrayList<Tenor>();
private List<Double> _parRates = new ArrayList<Double>();
private List<InstrumentDerivative> _cashNodes = new ArrayList<InstrumentDerivative>();
/**
* Restricted constructor.
*/
private Builder() {
}
/**
* Restricted copy constructor.
* @param beanToCopy the bean to copy from, not null
*/
private Builder(ImpliedDepositCurveData beanToCopy) {
this._tenors = new ArrayList<Tenor>(beanToCopy.getTenors());
this._parRates = new ArrayList<Double>(beanToCopy.getParRates());
this._cashNodes = new ArrayList<InstrumentDerivative>(beanToCopy.getCashNodes());
}
//-----------------------------------------------------------------------
@Override
public Object get(String propertyName) {
switch (propertyName.hashCode()) {
case -877322829: // tenors
return _tenors;
case 1157229426: // parRates
return _parRates;
case 741125950: // cashNodes
return _cashNodes;
default:
throw new NoSuchElementException("Unknown property: " + propertyName);
}
}
@SuppressWarnings("unchecked")
@Override
public Builder set(String propertyName, Object newValue) {
switch (propertyName.hashCode()) {
case -877322829: // tenors
this._tenors = (List<Tenor>) newValue;
break;
case 1157229426: // parRates
this._parRates = (List<Double>) newValue;
break;
case 741125950: // cashNodes
this._cashNodes = (List<InstrumentDerivative>) newValue;
break;
default:
throw new NoSuchElementException("Unknown property: " + propertyName);
}
return this;
}
@Override
public Builder set(MetaProperty<?> property, Object value) {
super.set(property, value);
return this;
}
@Override
public Builder setString(String propertyName, String value) {
setString(meta().metaProperty(propertyName), value);
return this;
}
@Override
public Builder setString(MetaProperty<?> property, String value) {
super.setString(property, value);
return this;
}
@Override
public Builder setAll(Map<String, ? extends Object> propertyValueMap) {
super.setAll(propertyValueMap);
return this;
}
@Override
public ImpliedDepositCurveData build() {
return new ImpliedDepositCurveData(
_tenors,
_parRates,
_cashNodes);
}
//-----------------------------------------------------------------------
/**
* Sets the {@code tenors} property in the builder.
* @param tenors the new value, not null
* @return this, for chaining, not null
*/
public Builder tenors(List<Tenor> tenors) {
JodaBeanUtils.notNull(tenors, "tenors");
this._tenors = tenors;
return this;
}
/**
* Sets the {@code tenors} property in the builder
* from an array of objects.
* @param tenors the new value, not null
* @return this, for chaining, not null
*/
public Builder tenors(Tenor... tenors) {
return tenors(Arrays.asList(tenors));
}
/**
* Sets the {@code parRates} property in the builder.
* @param parRates the new value, not null
* @return this, for chaining, not null
*/
public Builder parRates(List<Double> parRates) {
JodaBeanUtils.notNull(parRates, "parRates");
this._parRates = parRates;
return this;
}
/**
* Sets the {@code parRates} property in the builder
* from an array of objects.
* @param parRates the new value, not null
* @return this, for chaining, not null
*/
public Builder parRates(Double... parRates) {
return parRates(Arrays.asList(parRates));
}
/**
* Sets the {@code cashNodes} property in the builder.
* @param cashNodes the new value, not null
* @return this, for chaining, not null
*/
public Builder cashNodes(List<InstrumentDerivative> cashNodes) {
JodaBeanUtils.notNull(cashNodes, "cashNodes");
this._cashNodes = cashNodes;
return this;
}
/**
* Sets the {@code cashNodes} property in the builder
* from an array of objects.
* @param cashNodes the new value, not null
* @return this, for chaining, not null
*/
public Builder cashNodes(InstrumentDerivative... cashNodes) {
return cashNodes(Arrays.asList(cashNodes));
}
//-----------------------------------------------------------------------
@Override
public String toString() {
StringBuilder buf = new StringBuilder(128);
buf.append("ImpliedDepositCurveData.Builder{");
buf.append("tenors").append('=').append(JodaBeanUtils.toString(_tenors)).append(',').append(' ');
buf.append("parRates").append('=').append(JodaBeanUtils.toString(_parRates)).append(',').append(' ');
buf.append("cashNodes").append('=').append(JodaBeanUtils.toString(_cashNodes));
buf.append('}');
return buf.toString();
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}