com.opengamma.financial.analytics.ircurve.strips.PointsCurveNodeWithIdentifier.java Source code

Java tutorial

Introduction

Here is the source code for com.opengamma.financial.analytics.ircurve.strips.PointsCurveNodeWithIdentifier.java

Source

/**
 * 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 org.apache.commons.lang.ObjectUtils;
import org.joda.beans.BeanDefinition;
import org.joda.beans.PropertyDefinition;

import com.opengamma.id.ExternalId;
import java.util.Map;
import org.joda.beans.BeanBuilder;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

/**
 * Contains a curve node for when the market data is a spread over other market data.
 */
@BeanDefinition
public class PointsCurveNodeWithIdentifier extends CurveNodeWithIdentifier {
    /** The underlying market data id */
    @PropertyDefinition(validate = "notNull")
    private ExternalId _underlyingIdentifier;
    /** The underlying market data field */
    @PropertyDefinition(validate = "notNull")
    private String _underlyingDataField;

    /**
     * @param node The curve node, not null
     * @param id The market data id, not null
     * @param dataField The data field, not null
     * @param fieldType The field type, not null
     * @param underlyingId The underlying market data id, not null
     * @param underlyingField The underlying market data field, not null
     */
    public PointsCurveNodeWithIdentifier(final CurveNode node, final ExternalId id, final String dataField,
            final DataFieldType fieldType, final ExternalId underlyingId, final String underlyingField) {
        super(node, id, dataField, fieldType);
        _underlyingIdentifier = underlyingId;
        _underlyingDataField = underlyingField;
    }

    protected PointsCurveNodeWithIdentifier() {
        super();
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + _underlyingDataField.hashCode();
        result = prime * result + _underlyingIdentifier.hashCode();
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (!(obj instanceof PointsCurveNodeWithIdentifier)) {
            return false;
        }
        final PointsCurveNodeWithIdentifier other = (PointsCurveNodeWithIdentifier) obj;
        return ObjectUtils.equals(_underlyingIdentifier, other._underlyingIdentifier)
                && ObjectUtils.equals(_underlyingDataField, other._underlyingDataField);
    }

    //------------------------- AUTOGENERATED START -------------------------
    ///CLOVER:OFF
    /**
     * The meta-bean for {@code PointsCurveNodeWithIdentifier}.
     * @return the meta-bean, not null
     */
    public static PointsCurveNodeWithIdentifier.Meta meta() {
        return PointsCurveNodeWithIdentifier.Meta.INSTANCE;
    }

    static {
        JodaBeanUtils.registerMetaBean(PointsCurveNodeWithIdentifier.Meta.INSTANCE);
    }

    @Override
    public PointsCurveNodeWithIdentifier.Meta metaBean() {
        return PointsCurveNodeWithIdentifier.Meta.INSTANCE;
    }

    @Override
    protected Object propertyGet(String propertyName, boolean quiet) {
        switch (propertyName.hashCode()) {
        case 368639974: // underlyingIdentifier
            return getUnderlyingIdentifier();
        case -876884845: // underlyingDataField
            return getUnderlyingDataField();
        }
        return super.propertyGet(propertyName, quiet);
    }

    @Override
    protected void propertySet(String propertyName, Object newValue, boolean quiet) {
        switch (propertyName.hashCode()) {
        case 368639974: // underlyingIdentifier
            setUnderlyingIdentifier((ExternalId) newValue);
            return;
        case -876884845: // underlyingDataField
            setUnderlyingDataField((String) newValue);
            return;
        }
        super.propertySet(propertyName, newValue, quiet);
    }

    @Override
    protected void validate() {
        JodaBeanUtils.notNull(_underlyingIdentifier, "underlyingIdentifier");
        JodaBeanUtils.notNull(_underlyingDataField, "underlyingDataField");
        super.validate();
    }

    //-----------------------------------------------------------------------
    /**
     * Gets the underlying market data id
     * @return the value of the property, not null
     */
    public ExternalId getUnderlyingIdentifier() {
        return _underlyingIdentifier;
    }

    /**
     * Sets the underlying market data id
     * @param underlyingIdentifier  the new value of the property, not null
     */
    public void setUnderlyingIdentifier(ExternalId underlyingIdentifier) {
        JodaBeanUtils.notNull(underlyingIdentifier, "underlyingIdentifier");
        this._underlyingIdentifier = underlyingIdentifier;
    }

    /**
     * Gets the the {@code underlyingIdentifier} property.
     * @return the property, not null
     */
    public final Property<ExternalId> underlyingIdentifier() {
        return metaBean().underlyingIdentifier().createProperty(this);
    }

    //-----------------------------------------------------------------------
    /**
     * Gets the underlying market data field
     * @return the value of the property, not null
     */
    public String getUnderlyingDataField() {
        return _underlyingDataField;
    }

    /**
     * Sets the underlying market data field
     * @param underlyingDataField  the new value of the property, not null
     */
    public void setUnderlyingDataField(String underlyingDataField) {
        JodaBeanUtils.notNull(underlyingDataField, "underlyingDataField");
        this._underlyingDataField = underlyingDataField;
    }

    /**
     * Gets the the {@code underlyingDataField} property.
     * @return the property, not null
     */
    public final Property<String> underlyingDataField() {
        return metaBean().underlyingDataField().createProperty(this);
    }

    //-----------------------------------------------------------------------
    /**
     * The meta-bean for {@code PointsCurveNodeWithIdentifier}.
     */
    public static class Meta extends CurveNodeWithIdentifier.Meta {
        /**
         * The singleton instance of the meta-bean.
         */
        static final Meta INSTANCE = new Meta();

        /**
         * The meta-property for the {@code underlyingIdentifier} property.
         */
        private final MetaProperty<ExternalId> _underlyingIdentifier = DirectMetaProperty.ofReadWrite(this,
                "underlyingIdentifier", PointsCurveNodeWithIdentifier.class, ExternalId.class);
        /**
         * The meta-property for the {@code underlyingDataField} property.
         */
        private final MetaProperty<String> _underlyingDataField = DirectMetaProperty.ofReadWrite(this,
                "underlyingDataField", PointsCurveNodeWithIdentifier.class, String.class);
        /**
         * The meta-properties.
         */
        private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(this,
                (DirectMetaPropertyMap) super.metaPropertyMap(), "underlyingIdentifier", "underlyingDataField");

        /**
         * Restricted constructor.
         */
        protected Meta() {
        }

        @Override
        protected MetaProperty<?> metaPropertyGet(String propertyName) {
            switch (propertyName.hashCode()) {
            case 368639974: // underlyingIdentifier
                return _underlyingIdentifier;
            case -876884845: // underlyingDataField
                return _underlyingDataField;
            }
            return super.metaPropertyGet(propertyName);
        }

        @Override
        public BeanBuilder<? extends PointsCurveNodeWithIdentifier> builder() {
            return new DirectBeanBuilder<PointsCurveNodeWithIdentifier>(new PointsCurveNodeWithIdentifier());
        }

        @Override
        public Class<? extends PointsCurveNodeWithIdentifier> beanType() {
            return PointsCurveNodeWithIdentifier.class;
        }

        @Override
        public Map<String, MetaProperty<?>> metaPropertyMap() {
            return _metaPropertyMap$;
        }

        //-----------------------------------------------------------------------
        /**
         * The meta-property for the {@code underlyingIdentifier} property.
         * @return the meta-property, not null
         */
        public final MetaProperty<ExternalId> underlyingIdentifier() {
            return _underlyingIdentifier;
        }

        /**
         * The meta-property for the {@code underlyingDataField} property.
         * @return the meta-property, not null
         */
        public final MetaProperty<String> underlyingDataField() {
            return _underlyingDataField;
        }

    }

    ///CLOVER:ON
    //-------------------------- AUTOGENERATED END --------------------------
}