/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.analytics.ircurve.strips;
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.util.ArgumentChecker;
import com.opengamma.util.time.Tenor;
/**
* A bond node.
*/
@BeanDefinition
public class BondNode extends CurveNode {
/** Serialization version */
private static final long serialVersionUID = 1L;
/**
* The tenor.
*/
@PropertyDefinition(validate = "notNull")
private Tenor _maturityTenor;
/**
* For the builder.
*/
/* package */ BondNode() {
super();
}
/**
* Sets the node name to null.
* @param maturityTenor The tenor, not null
* @param curveNodeIdMapperName The curve node id mapper name, not null
*/
public BondNode(final Tenor maturityTenor, final String curveNodeIdMapperName) {
super(curveNodeIdMapperName);
setMaturityTenor(maturityTenor);
}
/**
* @param maturityTenor The tenor, not null
* @param curveNodeIdMapperName The curve node id mapper name, not null
* @param name The node name, not null
*/
public BondNode(final Tenor maturityTenor, final String curveNodeIdMapperName, final String name) {
super(curveNodeIdMapperName, name);
setMaturityTenor(maturityTenor);
}
@Override
public Tenor getResolvedMaturity() {
return _maturityTenor;
}
@Override
public <T> T accept(final CurveNodeVisitor<T> visitor) {
ArgumentChecker.notNull(visitor, "visitor");
return visitor.visitBondNode(this);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code BondNode}.
* @return the meta-bean, not null
*/
public static BondNode.Meta meta() {
return BondNode.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(BondNode.Meta.INSTANCE);
}
@Override
public BondNode.Meta metaBean() {
return BondNode.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the tenor.
* @return the value of the property, not null
*/
public Tenor getMaturityTenor() {
return _maturityTenor;
}
/**
* Sets the tenor.
* @param maturityTenor the new value of the property, not null
*/
public void setMaturityTenor(Tenor maturityTenor) {
JodaBeanUtils.notNull(maturityTenor, "maturityTenor");
this._maturityTenor = maturityTenor;
}
/**
* Gets the the {@code maturityTenor} property.
* @return the property, not null
*/
public final Property<Tenor> maturityTenor() {
return metaBean().maturityTenor().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public BondNode clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
BondNode other = (BondNode) obj;
return JodaBeanUtils.equal(getMaturityTenor(), other.getMaturityTenor()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getMaturityTenor());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(64);
buf.append("BondNode{");
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("maturityTenor").append('=').append(JodaBeanUtils.toString(getMaturityTenor())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code BondNode}.
*/
public static class Meta extends CurveNode.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code maturityTenor} property.
*/
private final MetaProperty<Tenor> _maturityTenor = DirectMetaProperty.ofReadWrite(
this, "maturityTenor", BondNode.class, Tenor.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"maturityTenor");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 45907375: // maturityTenor
return _maturityTenor;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends BondNode> builder() {
return new DirectBeanBuilder<BondNode>(new BondNode());
}
@Override
public Class<? extends BondNode> beanType() {
return BondNode.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code maturityTenor} property.
* @return the meta-property, not null
*/
public final MetaProperty<Tenor> maturityTenor() {
return _maturityTenor;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 45907375: // maturityTenor
return ((BondNode) bean).getMaturityTenor();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 45907375: // maturityTenor
((BondNode) bean).setMaturityTenor((Tenor) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((BondNode) bean)._maturityTenor, "maturityTenor");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}