X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FProfile.java;h=61cf2911f372e93aa33b329ee9a81e14353689af;hb=b4aa901eb74222ef576aa429c346ac7c19010b0e;hp=8c1e80509d133b5a08fdf1a67879cd45ffdcead3;hpb=ffbea903358cf376a369987529e07d607647c41c;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 8c1e805..61cf291 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -22,7 +22,6 @@ import static com.google.common.base.Optional.fromNullable; import static com.google.common.base.Optional.of; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.UUID.randomUUID; @@ -92,98 +91,43 @@ public class Profile implements Fingerprintable { return sone; } - /** - * Returns the first name. - * - * @return The first name - */ public String getFirstName() { return name.getFirst().orNull(); } - /** - * Returns the middle name(s). - * - * @return The middle name - */ public String getMiddleName() { return name.getMiddle().orNull(); } - /** - * Returns the last name. - * - * @return The last name - */ public String getLastName() { return name.getLast().orNull(); } - /** - * Returns the day of the birth date. - * - * @return The day of the birth date (from 1 to 31) - */ public Integer getBirthDay() { return birthDate.getDay().orNull(); } - /** - * Returns the month of the birth date. - * - * @return The month of the birth date (from 1 to 12) - */ public Integer getBirthMonth() { return birthDate.getMonth().orNull(); } - /** - * Returns the year of the birth date. - * - * @return The year of the birth date - */ public Integer getBirthYear() { return birthDate.getYear().orNull(); } - /** - * 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 avatarId - * The ID of the new avatar image - * @return This profile - */ public Profile setAvatar(Optional avatarId) { this.avatar = avatarId.orNull(); return this; } - /** - * Returns the fields of this profile. - * - * @return The fields of this profile - */ public List getFields() { return new ArrayList(fields); } - /** - * Returns whether this profile contains the given field. - * - * @param field - * The field to check for - * @return {@code true} if this profile contains the field, false otherwise - */ public boolean hasField(Field field) { return fields.contains(field); } @@ -207,19 +151,10 @@ public class Profile implements Fingerprintable { return absent(); } - /** - * Appends a new field to the list of fields. - * - * @param fieldName - * The name of the new field - * @return The new field - * @throws IllegalArgumentException - * if the name is not valid - */ public Field addField(String fieldName) throws IllegalArgumentException { checkNotNull(fieldName, "fieldName must not be null"); checkArgument(fieldName.length() > 0, "fieldName must not be empty"); - checkState(!getFieldByName(fieldName).isPresent(), "fieldName must be unique"); + checkArgument(!getFieldByName(fieldName).isPresent(), "fieldName must be unique"); @SuppressWarnings("synthetic-access") Field field = new Field(fieldName); fields.add(field); @@ -349,9 +284,6 @@ public class Profile implements Fingerprintable { // INTERFACE Fingerprintable // - /** - * {@inheritDoc} - */ @Override public String getFingerprint() { Hasher hash = Hashing.sha256().newHasher(); @@ -363,7 +295,9 @@ public class Profile implements Fingerprintable { } hash.putString("ContactInformation("); for (Field field : fields) { - hash.putString(field.getName()).putString("(").putString(field.getValue()).putString(")"); + if (field.getValue() != null) { + hash.putString(field.getName()).putString("(").putString(field.getValue()).putString(")"); + } } hash.putString(")"); hash.putString(")");