/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.livedata.rest;

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.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.engine.value.ValueRequirement;
import com.opengamma.engine.value.ValueSpecification;
import com.opengamma.util.PublicSPI;

/**
 *
 */
@PublicSPI
@BeanDefinition
public class AddValueRequest extends DirectBean {

  @PropertyDefinition
  private ValueRequirement _valueRequirement;

  @PropertyDefinition
  private ValueSpecification _valueSpecification;

  @PropertyDefinition
  private Object _value;

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

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

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

  //-----------------------------------------------------------------------
  /**
   * Gets the valueRequirement.
   * @return the value of the property
   */
  public ValueRequirement getValueRequirement() {
    return _valueRequirement;
  }

  /**
   * Sets the valueRequirement.
   * @param valueRequirement  the new value of the property
   */
  public void setValueRequirement(ValueRequirement valueRequirement) {
    this._valueRequirement = valueRequirement;
  }

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

  //-----------------------------------------------------------------------
  /**
   * Gets the valueSpecification.
   * @return the value of the property
   */
  public ValueSpecification getValueSpecification() {
    return _valueSpecification;
  }

  /**
   * Sets the valueSpecification.
   * @param valueSpecification  the new value of the property
   */
  public void setValueSpecification(ValueSpecification valueSpecification) {
    this._valueSpecification = valueSpecification;
  }

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

  //-----------------------------------------------------------------------
  /**
   * Gets the value.
   * @return the value of the property
   */
  public Object getValue() {
    return _value;
  }

  /**
   * Sets the value.
   * @param value  the new value of the property
   */
  public void setValue(Object value) {
    this._value = value;
  }

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

  //-----------------------------------------------------------------------
  @Override
  public AddValueRequest clone() {
    return JodaBeanUtils.cloneAlways(this);
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if (obj != null && obj.getClass() == this.getClass()) {
      AddValueRequest other = (AddValueRequest) obj;
      return JodaBeanUtils.equal(getValueRequirement(), other.getValueRequirement()) &&
          JodaBeanUtils.equal(getValueSpecification(), other.getValueSpecification()) &&
          JodaBeanUtils.equal(getValue(), other.getValue());
    }
    return false;
  }

  @Override
  public int hashCode() {
    int hash = getClass().hashCode();
    hash = hash * 31 + JodaBeanUtils.hashCode(getValueRequirement());
    hash = hash * 31 + JodaBeanUtils.hashCode(getValueSpecification());
    hash = hash * 31 + JodaBeanUtils.hashCode(getValue());
    return hash;
  }

  @Override
  public String toString() {
    StringBuilder buf = new StringBuilder(128);
    buf.append("AddValueRequest{");
    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("valueRequirement").append('=').append(JodaBeanUtils.toString(getValueRequirement())).append(',').append(' ');
    buf.append("valueSpecification").append('=').append(JodaBeanUtils.toString(getValueSpecification())).append(',').append(' ');
    buf.append("value").append('=').append(JodaBeanUtils.toString(getValue())).append(',').append(' ');
  }

  //-----------------------------------------------------------------------
  /**
   * The meta-bean for {@code AddValueRequest}.
   */
  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 valueRequirement} property.
     */
    private final MetaProperty<ValueRequirement> _valueRequirement = DirectMetaProperty.ofReadWrite(
        this, "valueRequirement", AddValueRequest.class, ValueRequirement.class);
    /**
     * The meta-property for the {@code valueSpecification} property.
     */
    private final MetaProperty<ValueSpecification> _valueSpecification = DirectMetaProperty.ofReadWrite(
        this, "valueSpecification", AddValueRequest.class, ValueSpecification.class);
    /**
     * The meta-property for the {@code value} property.
     */
    private final MetaProperty<Object> _value = DirectMetaProperty.ofReadWrite(
        this, "value", AddValueRequest.class, Object.class);
    /**
     * The meta-properties.
     */
    private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
        this, null,
        "valueRequirement",
        "valueSpecification",
        "value");

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

    @Override
    protected MetaProperty<?> metaPropertyGet(String propertyName) {
      switch (propertyName.hashCode()) {
        case -755281390:  // valueRequirement
          return _valueRequirement;
        case 7765778:  // valueSpecification
          return _valueSpecification;
        case 111972721:  // value
          return _value;
      }
      return super.metaPropertyGet(propertyName);
    }

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

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

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

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

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

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

    //-----------------------------------------------------------------------
    @Override
    protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
      switch (propertyName.hashCode()) {
        case -755281390:  // valueRequirement
          return ((AddValueRequest) bean).getValueRequirement();
        case 7765778:  // valueSpecification
          return ((AddValueRequest) bean).getValueSpecification();
        case 111972721:  // value
          return ((AddValueRequest) bean).getValue();
      }
      return super.propertyGet(bean, propertyName, quiet);
    }

    @Override
    protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
      switch (propertyName.hashCode()) {
        case -755281390:  // valueRequirement
          ((AddValueRequest) bean).setValueRequirement((ValueRequirement) newValue);
          return;
        case 7765778:  // valueSpecification
          ((AddValueRequest) bean).setValueSpecification((ValueSpecification) newValue);
          return;
        case 111972721:  // value
          ((AddValueRequest) bean).setValue((Object) newValue);
          return;
      }
      super.propertySet(bean, propertyName, newValue, quiet);
    }

  }

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