// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import com.google.common.base.Objects;
import java.io.IOException;

// === xdr source ============================================================

//  struct Price
//  {
//      int32 n; // numerator
//      int32 d; // denominator
//  };

//  ===========================================================================
public class Price implements XdrElement {
  public Price() {}

  private Int32 n;

  public Int32 getN() {
    return this.n;
  }

  public void setN(Int32 value) {
    this.n = value;
  }

  private Int32 d;

  public Int32 getD() {
    return this.d;
  }

  public void setD(Int32 value) {
    this.d = value;
  }

  public static void encode(XdrDataOutputStream stream, Price encodedPrice) throws IOException {
    Int32.encode(stream, encodedPrice.n);
    Int32.encode(stream, encodedPrice.d);
  }

  public void encode(XdrDataOutputStream stream) throws IOException {
    encode(stream, this);
  }

  public static Price decode(XdrDataInputStream stream) throws IOException {
    Price decodedPrice = new Price();
    decodedPrice.n = Int32.decode(stream);
    decodedPrice.d = Int32.decode(stream);
    return decodedPrice;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(this.n, this.d);
  }

  @Override
  public boolean equals(Object object) {
    if (!(object instanceof Price)) {
      return false;
    }

    Price other = (Price) object;
    return Objects.equal(this.n, other.n) && Objects.equal(this.d, other.d);
  }

  public static final class Builder {
    private Int32 n;
    private Int32 d;

    public Builder n(Int32 n) {
      this.n = n;
      return this;
    }

    public Builder d(Int32 d) {
      this.d = d;
      return this;
    }

    public Price build() {
      Price val = new Price();
      val.setN(n);
      val.setD(d);
      return val;
    }
  }
}
