2 * Sone - Trust.java - Copyright © 2010–2016 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.
27 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31 /** Explicitely assigned trust. */
32 private final Integer explicit;
34 /** Implicitely calculated trust. */
35 private final Integer implicit;
37 /** The distance from the owner of the trust tree. */
38 private final Integer distance;
41 * Creates a new trust container.
50 public Trust(Integer explicit, Integer implicit, Integer distance) {
51 this.explicit = explicit;
52 this.implicit = implicit;
53 this.distance = distance;
57 * Returns the trust explicitely assigned to an identity.
59 * @return The explicitely assigned trust, or {@code null} if the identity
60 * is not in the own identity’s trust tree
62 public Integer getExplicit() {
67 * Returns the implicitely assigned trust, or the calculated trust.
69 * @return The calculated trust, or {@code null} if the identity is not in
70 * the own identity’s trust tree
72 public Integer getImplicit() {
77 * Returns the distance of the trusted identity from the trusting identity.
79 * @return The distance from the own identity, or {@code null} if the
80 * identity is not in the own identity’s trust tree
82 public Integer getDistance() {
87 public boolean equals(Object object) {
88 if (!(object instanceof Trust)) {
91 Trust trust = (Trust) object;
92 return equal(getExplicit(), trust.getExplicit()) && equal(getImplicit(), trust.getImplicit()) && equal(getDistance(), trust.getDistance());
96 public int hashCode() {
97 return Objects.hashCode(explicit, implicit, distance);
102 public String toString() {
103 return getClass().getName() + "[explicit=" + explicit + ",implicit=" + implicit + ",distance=" + distance + "]";