package net.pterodactylus.sone.freenet.wot;
+import static com.google.common.base.Objects.equal;
+
+import com.google.common.base.Objects;
+
/**
* Container class for trust in the web of trust.
*
}
@Override
+ public int hashCode() {
+ return Objects.hashCode(getExplicit(), getImplicit(), getDistance());
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Trust)) {
+ return false;
+ }
+ Trust trust = (Trust) object;
+ return equal(getExplicit(), trust.getExplicit()) && equal(getImplicit(), trust.getImplicit()) && equal(getDistance(), trust.getDistance());
+ }
+
+ @Override
public String toString() {
return getClass().getName() + "[explicit=" + explicit + ",implicit=" + implicit + ",distance=" + distance + "]";
}
assertThat(trust.getDistance(), nullValue());
}
+ @Test
+ public void equalTrustsHaveTheSameHashCode() {
+ Trust trust1 = new Trust(5, 17, 2);
+ Trust trust2 = new Trust(5, 17, 2);
+ assertThat(trust1, is(trust2));
+ assertThat(trust1.hashCode(), is(trust2.hashCode()));
+ }
+
}