From 8cbc1e2bc1a94d2ceb6a635389ed4791a08a4889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 7 Dec 2011 07:21:53 +0100 Subject: [PATCH] Store avatar image in Sone. --- .../java/net/pterodactylus/sone/data/Sone.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 8b2ec2a..e36a306 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -173,6 +173,9 @@ public class Sone implements Fingerprintable, Comparable { /** Sone-specific options. */ private final Options options = new Options(); + /** The avatar of this Sone. */ + private volatile String avatar; + /** * Creates a new Sone. * @@ -764,6 +767,34 @@ public class Sone implements Fingerprintable, Comparable { } /** + * Returns the ID of the currently selected avatar image. + * + * @return The ID of the currently selected avatar image, or {@code null} if + * no avatar is selected. + */ + public String getAvatar() { + return avatar; + } + + /** + * Sets the avatar image. + * + * @param avatar + * The new avatar image, or {@code null} to not select an avatar + * image. + * @return This Sone + */ + public Sone setAvatar(Image avatar) { + if (avatar == null) { + this.avatar = null; + return this; + } + Validation.begin().isEqual("Image Owner", avatar.getSone(), this).check(); + this.avatar = avatar.getId(); + return this; + } + + /** * Returns Sone-specific options. * * @return The options of this Sone @@ -820,6 +851,8 @@ public class Sone implements Fingerprintable, Comparable { } fingerprint.append(')'); + fingerprint.append("Avatar(").append(avatar).append(')'); + return fingerprint.toString(); } -- 2.7.4