From 5e30da746a4bf60db229bded083bc0d24efa5c13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 1 Jan 2011 14:31:53 +0100 Subject: [PATCH] Add Fingerprintable interface. --- .../pterodactylus/sone/data/Fingerprintable.java | 36 ++++++++++++++++++++++ .../java/net/pterodactylus/sone/data/Sone.java | 14 ++++----- 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/main/java/net/pterodactylus/sone/data/Fingerprintable.java diff --git a/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java b/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java new file mode 100644 index 0000000..013e0b3 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java @@ -0,0 +1,36 @@ +/* + * Sone - Fingerprintable.java - Copyright © 2011 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.data; + +/** + * Interface for objects that can create a fingerprint of themselves, e.g. to + * detect modifications. The fingerprint should only contain original + * information; derived information should not be included. + * + * @author David ‘Bombe’ Roden + */ +public interface Fingerprintable { + + /** + * Returns the fingerprint of this object. + * + * @return The fingerprint of this object + */ + public String getFingerprint(); + +} diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 7d4f7ef..c145b82 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -40,7 +40,7 @@ import freenet.keys.FreenetURI; * * @author David ‘Bombe’ Roden */ -public class Sone { +public class Sone implements Fingerprintable { /** comparator that sorts Sones by their nice name. */ public static final Comparator NICE_NAME_COMPARATOR = new Comparator() { @@ -580,14 +580,14 @@ public class Sone { return this; } + // + // FINGERPRINTABLE METHODS + // + /** - * Returns a fingerprint of this Sone. The fingerprint only depends on data - * that is actually stored when a Sone is inserted. The fingerprint can be - * used to detect changes in Sone data and can also be used to detect if - * previous changes are reverted. - * - * @return The fingerprint of this Sone + * {@inheritDoc} */ + @Override public synchronized String getFingerprint() { StringBuilder fingerprint = new StringBuilder(); fingerprint.append("Profile("); -- 2.7.4