// 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 TransactionResultPair
//  {
//      Hash transactionHash;
//      TransactionResult result; // result for the transaction
//  };

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

  private Hash transactionHash;

  public Hash getTransactionHash() {
    return this.transactionHash;
  }

  public void setTransactionHash(Hash value) {
    this.transactionHash = value;
  }

  private TransactionResult result;

  public TransactionResult getResult() {
    return this.result;
  }

  public void setResult(TransactionResult value) {
    this.result = value;
  }

  public static void encode(
      XdrDataOutputStream stream, TransactionResultPair encodedTransactionResultPair)
      throws IOException {
    Hash.encode(stream, encodedTransactionResultPair.transactionHash);
    TransactionResult.encode(stream, encodedTransactionResultPair.result);
  }

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

  public static TransactionResultPair decode(XdrDataInputStream stream) throws IOException {
    TransactionResultPair decodedTransactionResultPair = new TransactionResultPair();
    decodedTransactionResultPair.transactionHash = Hash.decode(stream);
    decodedTransactionResultPair.result = TransactionResult.decode(stream);
    return decodedTransactionResultPair;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(this.transactionHash, this.result);
  }

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

    TransactionResultPair other = (TransactionResultPair) object;
    return Objects.equal(this.transactionHash, other.transactionHash)
        && Objects.equal(this.result, other.result);
  }

  public static final class Builder {
    private Hash transactionHash;
    private TransactionResult result;

    public Builder transactionHash(Hash transactionHash) {
      this.transactionHash = transactionHash;
      return this;
    }

    public Builder result(TransactionResult result) {
      this.result = result;
      return this;
    }

    public TransactionResultPair build() {
      TransactionResultPair val = new TransactionResultPair();
      val.setTransactionHash(transactionHash);
      val.setResult(result);
      return val;
    }
  }
}
