Implementing the equals and hashcode methods for the Authority class
This commit is contained in:
parent
f93f91fc1f
commit
5fa4d8667f
1 changed files with 22 additions and 1 deletions
|
@ -61,7 +61,7 @@ public class Authority implements GrapheneSerializable {
|
||||||
this.account_auths = accountAuthorities;
|
this.account_auths = accountAuthorities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PublicKey> getKeyAuths(){
|
public List<PublicKey> getKeyAuthList(){
|
||||||
ArrayList<PublicKey> keys = new ArrayList<>();
|
ArrayList<PublicKey> keys = new ArrayList<>();
|
||||||
for(PublicKey pk : key_auths.keySet()){
|
for(PublicKey pk : key_auths.keySet()){
|
||||||
keys.add(pk);
|
keys.add(pk);
|
||||||
|
@ -69,6 +69,14 @@ public class Authority implements GrapheneSerializable {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<PublicKey, Integer> getKeyAuths(){
|
||||||
|
return this.key_auths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<UserAccount, Integer> getAccountAuths(){
|
||||||
|
return this.account_auths;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJsonString() {
|
public String toJsonString() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -138,6 +146,19 @@ public class Authority implements GrapheneSerializable {
|
||||||
return Bytes.toArray(byteArray);
|
return Bytes.toArray(byteArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
Authority authority = (Authority) obj;
|
||||||
|
HashMap<PublicKey, Integer> keyAuths = authority.getKeyAuths();
|
||||||
|
HashMap<UserAccount, Integer> accountAuths = authority.getAccountAuths();
|
||||||
|
System.out.println("key auths match: "+this.key_auths.equals(keyAuths));
|
||||||
|
System.out.println("account auths match: "+this.account_auths.equals(accountAuths));
|
||||||
|
System.out.println("weight threshold matches: "+(this.weight_threshold == authority.weight_threshold));
|
||||||
|
return this.key_auths.equals(keyAuths) &&
|
||||||
|
this.account_auths.equals(accountAuths) &&
|
||||||
|
this.weight_threshold == authority.weight_threshold;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom deserializer used while parsing the 'get_account_by_name' API call response.
|
* Custom deserializer used while parsing the 'get_account_by_name' API call response.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue