/** Creates an instance of Contact and sets the contactOwner and contactOwnerKeyId */ public Contact( Identity owner, String alias, Collection<DropURL> dropUrls, QblECPublicKey pubKey) { super(dropUrls); this.contactOwner = owner; this.contactOwnerKeyId = owner.getKeyIdentifier(); this.setEcPublicKey(pubKey); this.alias = alias; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((contactOwner == null) ? 0 : contactOwner.hashCode()); result = prime * result + ((contactOwnerKeyId == null) ? 0 : contactOwnerKeyId.hashCode()); result = prime * result + ((ecPublicKey == null) ? 0 : ecPublicKey.hashCode()); result = prime * result + ((alias == null) ? 0 : alias.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Contact other = (Contact) obj; if (contactOwner == null) { if (other.contactOwner != null) return false; } else if (!contactOwner.equals(other.contactOwner)) return false; if (contactOwnerKeyId == null) { if (other.contactOwnerKeyId != null) return false; } else if (!contactOwnerKeyId.equals(other.contactOwnerKeyId)) return false; if (ecPublicKey == null) { if (other.ecPublicKey != null) return false; } else if (!ecPublicKey.equals(other.ecPublicKey)) return false; if (alias == null) { if (other.alias != null) return false; } else if (!alias.equals(other.alias)) return false; return true; }
/** * Sets the contact owning identity * * @param identity */ public void setContactOwner(Identity identity) { this.contactOwner = identity; this.contactOwnerKeyId = identity.getKeyIdentifier(); }