X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FProfile.java;h=679196b14342f4df5338cf64f373e13f6483e7b8;hb=50999afc14ced32f8f15b7512a896bbac1e61562;hp=1f80248ebc864c7169dc9e406b56a8b29d4d35fe;hpb=28667abdadc0573ac106542f1fd42ab5775ec415;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 1f80248..679196b 100644
--- a/src/main/java/net/pterodactylus/sone/data/Profile.java
+++ b/src/main/java/net/pterodactylus/sone/data/Profile.java
@@ -243,7 +243,7 @@ public class Profile implements Fingerprintable {
return this;
}
checkArgument(avatar.getSone().equals(sone), "avatar must belong to Sone");
- this.avatar = avatar.getId();
+ this.avatar = avatar.getInternalId();
return this;
}
@@ -325,12 +325,14 @@ public class Profile implements Fingerprintable {
*/
public Field addField(String fieldName) throws IllegalArgumentException {
checkNotNull(fieldName, "fieldName must not be null");
- checkArgument(fieldName.length() > 0, "fieldName must not be empty");
+ if (fieldName.length() == 0) {
+ throw new EmptyFieldName();
+ }
if (getFieldByName(fieldName) != null) {
throw new DuplicateField();
}
@SuppressWarnings("synthetic-access")
- Field field = new Field().setName(fieldName);
+ Field field = new Field().setName(fieldName).setValue("");
fields.add(field);
return field;
}
@@ -556,6 +558,13 @@ public class Profile implements Fingerprintable {
}
/**
+ * Exception that signals the addition of a field with an empty name.
+ *
+ * @author David âBombeâ Roden
+ */
+ public static class EmptyFieldName extends IllegalArgumentException { }
+
+ /**
* Exception that signals the addition of a field that already exists.
*
* @author David âBombeâ Roden