From 64cea07df3dad99db72ee557a0be5184c0d2db26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Oct 2019 10:03:23 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Replace=20Trust=20with=20Kotlin?= =?utf8?q?=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/sone/freenet/wot/Trust.java | 104 --------------------- .../net/pterodactylus/sone/freenet/wot/Trust.kt | 23 +++++ 2 files changed, 23 insertions(+), 104 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java create mode 100644 src/main/kotlin/net/pterodactylus/sone/freenet/wot/Trust.kt diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java deleted file mode 100644 index 2da00f6..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Sone - Trust.java - Copyright © 2010–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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. - */ -public class Trust { - - /** Explicitely assigned trust. */ - private final Integer explicit; - - /** Implicitely calculated trust. */ - private final Integer implicit; - - /** The distance from the owner of the trust tree. */ - private final Integer distance; - - /** - * Creates a new trust container. - * - * @param explicit - * The explicit trust - * @param implicit - * The implicit trust - * @param distance - * The distance - */ - public Trust(Integer explicit, Integer implicit, Integer distance) { - this.explicit = explicit; - this.implicit = implicit; - this.distance = distance; - } - - /** - * Returns the trust explicitely assigned to an identity. - * - * @return The explicitely assigned trust, or {@code null} if the identity - * is not in the own identity’s trust tree - */ - public Integer getExplicit() { - return explicit; - } - - /** - * Returns the implicitely assigned trust, or the calculated trust. - * - * @return The calculated trust, or {@code null} if the identity is not in - * the own identity’s trust tree - */ - public Integer getImplicit() { - return implicit; - } - - /** - * Returns the distance of the trusted identity from the trusting identity. - * - * @return The distance from the own identity, or {@code null} if the - * identity is not in the own identity’s trust tree - */ - public Integer getDistance() { - return distance; - } - - @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 int hashCode() { - return Objects.hashCode(explicit, implicit, distance); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return getClass().getName() + "[explicit=" + explicit + ",implicit=" + implicit + ",distance=" + distance + "]"; - } - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/Trust.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/Trust.kt new file mode 100644 index 0000000..9242de9 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/Trust.kt @@ -0,0 +1,23 @@ +/* + * Sone - Trust.java - Copyright © 2010–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.freenet.wot + +/** + * Container class for trust in the web of trust. + */ +data class Trust(val explicit: Int?, val implicit: Int?, val distance: Int?) -- 2.7.4