2 * Sone - Trust.java - Copyright © 2010–2013 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.freenet.wot;
20 import java.util.Objects;
23 * Container class for trust in the web of trust.
25 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29 private final Integer explicit;
30 private final Integer implicit;
31 private final Integer distance;
33 public Trust(Integer explicit, Integer implicit, Integer distance) {
34 this.explicit = explicit;
35 this.implicit = implicit;
36 this.distance = distance;
40 * Returns the trust explicitely assigned to an identity.
42 * @return The explicitely assigned trust, or {@code null} if the identity
43 * is not in the own identity’s trust tree
45 public Integer getExplicit() {
50 * Returns the implicitely assigned trust, or the calculated trust.
52 * @return The calculated trust, or {@code null} if the identity is not in
53 * the own identity’s trust tree
55 public Integer getImplicit() {
60 * Returns the distance of the trusted identity from the trusting identity.
62 * @return The distance from the own identity, or {@code null} if the
63 * identity is not in the own identity’s trust tree
65 public Integer getDistance() {
70 public boolean equals(Object object) {
71 if (!(object instanceof Trust)) {
74 Trust trust = (Trust) object;
75 return Objects.equals(getExplicit(), trust.getExplicit())
76 && Objects.equals(getImplicit(), trust.getImplicit())
77 && Objects.equals(getDistance(), trust.getDistance());
81 public String toString() {
82 return getClass().getName() + "[explicit=" + explicit + ",implicit=" + implicit + ",distance=" + distance + "]";