2 * Sone - Trust.java - Copyright © 2010–2019 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.freenet.wot;
20 import static com.google.common.base.Objects.equal;
22 import com.google.common.base.Objects;
25 * Container class for trust in the web of trust.
29 /** Explicitely assigned trust. */
30 private final Integer explicit;
32 /** Implicitely calculated trust. */
33 private final Integer implicit;
35 /** The distance from the owner of the trust tree. */
36 private final Integer distance;
39 * Creates a new trust container.
48 public Trust(Integer explicit, Integer implicit, Integer distance) {
49 this.explicit = explicit;
50 this.implicit = implicit;
51 this.distance = distance;
55 * Returns the trust explicitely assigned to an identity.
57 * @return The explicitely assigned trust, or {@code null} if the identity
58 * is not in the own identity’s trust tree
60 public Integer getExplicit() {
65 * Returns the implicitely assigned trust, or the calculated trust.
67 * @return The calculated trust, or {@code null} if the identity is not in
68 * the own identity’s trust tree
70 public Integer getImplicit() {
75 * Returns the distance of the trusted identity from the trusting identity.
77 * @return The distance from the own identity, or {@code null} if the
78 * identity is not in the own identity’s trust tree
80 public Integer getDistance() {
85 public boolean equals(Object object) {
86 if (!(object instanceof Trust)) {
89 Trust trust = (Trust) object;
90 return equal(getExplicit(), trust.getExplicit()) && equal(getImplicit(), trust.getImplicit()) && equal(getDistance(), trust.getDistance());
94 public int hashCode() {
95 return Objects.hashCode(explicit, implicit, distance);
100 public String toString() {
101 return getClass().getName() + "[explicit=" + explicit + ",implicit=" + implicit + ",distance=" + distance + "]";