X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FProfile.java;h=2792f46b5fef04fef39f97869d0e4736277c938d;hb=01a3dd65fb1bf371a6b0febcaf203d40e430f7a9;hp=fcea73761c5ca75190437452ff51892bbd7e76f7;hpb=0540df74082148c5b14d8e968157b6113368a130;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index fcea737..2792f46 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -42,7 +42,7 @@ public class Profile implements Fingerprintable { /** The Sone this profile belongs to. */ private final Sone sone; - private volatile Name name; + private volatile Name name = new Name(); private volatile BirthDate birthDate = new BirthDate(); /** The ID of the avatar image. */ @@ -155,18 +155,12 @@ public class Profile implements Fingerprintable { /** * Sets the avatar image. * - * @param avatar - * The new avatar image, or {@code null} to not select an avatar - * image. - * @return This Sone + * @param avatarId + * The ID of the new avatar image + * @return This profile */ - public Profile setAvatar(Image avatar) { - if (avatar == null) { - this.avatar = null; - return this; - } - checkArgument(avatar.getSone().equals(sone), "avatar must belong to Sone"); - this.avatar = avatar.getId(); + public Profile setAvatar(Optional avatarId) { + this.avatar = avatarId.orNull(); return this; } @@ -431,6 +425,12 @@ public class Profile implements Fingerprintable { this.id = checkNotNull(id, "id must not be null"); } + public Field(String id, String name, String value) { + this.id = checkNotNull(id, "id must not be null"); + this.name = name; + this.value = value; + } + /** * Returns the ID of this field. * @@ -520,6 +520,10 @@ public class Profile implements Fingerprintable { private final Optional middle; private final Optional last; + public Name() { + this(Optional.absent(), Optional.absent(), Optional.absent()); + } + public Name(Optional first, Optional middle, Optional last) { this.first = first; this.middle = middle;