package org.mastercoin.rpc;

import com.google.bitcoin.core.Address;

import java.math.BigDecimal;

/**
 * Balance data for a specific Mastercoin CurrencyID in a single Bitcoin address
 *
 * A Java representation of the JSON entry returned by getallbalancesforid_MP
 */
public class MPBalanceEntry {
    private Address address;
    private BigDecimal balance;
    private BigDecimal reserved;

    public MPBalanceEntry(Address address, BigDecimal balance, BigDecimal reserved) {
        this.address = address;
        this.balance = balance;
        this.reserved = reserved;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof MPBalanceEntry)) {
            return false;
        }
        MPBalanceEntry e = (MPBalanceEntry) o;
        if (    (this.address == e.address) &&
                (this.balance == e.balance) &&
                (this.reserved == e.reserved) ) {
            return true;
        } else {
            return false;
        }
    }

    public Address getAddress() {
        return address;
    }

    public BigDecimal getBalance() {
        return balance;
    }

    public BigDecimal getReserved() {
        return reserved;
    }
}

@@ -647,53 +647,84 @@
 if (
-!(o instanceof MPBalanceEntry)) %7B%0A           
+this == o) return true;%0A        if (o == null %7C%7C getClass() != o.getClass())
  ret
@@ -730,33 +730,24 @@
 turn false;%0A
-        %7D
 %0A        MPB
@@ -758,17 +758,20 @@
 ceEntry 
-e
+that
  = (MPBa
@@ -785,16 +785,17 @@
 try) o;%0A
+%0A
         
@@ -802,30 +802,28 @@
 if (
-    (this.address == e
+!address.equals(that
 .add
@@ -831,94 +831,114 @@
 ess)
- &&%0A                (this.balance == e.balance) &&%0A                (this.reserved == e
+) return false;%0A        if (!balance.equals(that.balance)) return false;%0A        if (!reserved.equals(that
 .res
@@ -947,22 +947,33 @@
 ved)
- 
 ) 
-%7B%0A 
+return false;%0A%0A
         
    r
@@ -964,27 +964,24 @@
 e;%0A%0A        
-   
 return true;
@@ -989,56 +989,219 @@
     
+%7D%0A%0A
     
-%7D else %7B%0A            return false;%0A        %7D
+@Override%0A    public int hashCode() %7B%0A        int result = address.hashCode();%0A        result = 31 * result + balance.hashCode();%0A        result = 31 * result + reserved.hashCode();%0A        return result;
 %0A   

Correct equals() implementation, add hashCode()