X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FProfile.java;h=64aeae4ccd212e6c05d54915632590662e352cd5;hb=3abc078471d7e7516599eda01de011a23c328d63;hp=059c33e5a9783e8845a4c43f570ace48cdeda5c6;hpb=04b249af1615b35630f7b21486d6bc5cc1610e69;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 059c33e..64aeae4 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -20,6 +20,7 @@ package net.pterodactylus.sone.data; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -33,9 +34,6 @@ import net.pterodactylus.util.validation.Validation; */ public class Profile implements Fingerprintable { - /** Whether the profile was modified. */ - private volatile boolean modified; - /** The first name. */ private volatile String firstName; @@ -91,18 +89,6 @@ public class Profile implements Fingerprintable { // /** - * Returns whether this profile was modified after creation. To clear the - * “is modified” flag you need to create a new profile from this one using - * the {@link #Profile(Profile)} constructor. - * - * @return {@code true} if this profile was modified after creation, - * {@code false} otherwise - */ - public boolean isModified() { - return modified; - } - - /** * Returns the first name. * * @return The first name @@ -119,7 +105,6 @@ public class Profile implements Fingerprintable { * @return This profile (for method chaining) */ public Profile setFirstName(String firstName) { - modified |= ((firstName != null) && (!firstName.equals(this.firstName))) || (this.firstName != null); this.firstName = firstName; return this; } @@ -141,7 +126,6 @@ public class Profile implements Fingerprintable { * @return This profile (for method chaining) */ public Profile setMiddleName(String middleName) { - modified |= ((middleName != null) && (!middleName.equals(this.middleName))) || (this.middleName != null); this.middleName = middleName; return this; } @@ -163,7 +147,6 @@ public class Profile implements Fingerprintable { * @return This profile (for method chaining) */ public Profile setLastName(String lastName) { - modified |= ((lastName != null) && (!lastName.equals(this.lastName))) || (this.lastName != null); this.lastName = lastName; return this; } @@ -185,7 +168,6 @@ public class Profile implements Fingerprintable { * @return This profile (for method chaining) */ public Profile setBirthDay(Integer birthDay) { - modified |= ((birthDay != null) && (!birthDay.equals(this.birthDay))) || (this.birthDay != null); this.birthDay = birthDay; return this; } @@ -207,7 +189,6 @@ public class Profile implements Fingerprintable { * @return This profile (for method chaining) */ public Profile setBirthMonth(Integer birthMonth) { - modified |= ((birthMonth != null) && (!birthMonth.equals(this.birthMonth))) || (this.birthMonth != null); this.birthMonth = birthMonth; return this; } @@ -229,7 +210,6 @@ public class Profile implements Fingerprintable { * @return This profile (for method chaining) */ public Profile setBirthYear(Integer birthYear) { - modified |= ((birthYear != null) && (!birthYear.equals(this.birthYear))) || (this.birthYear != null); this.birthYear = birthYear; return this; } @@ -353,10 +333,24 @@ public class Profile implements Fingerprintable { * * @return The fields of this profile */ - public List getFields() { + public List getFieldNames() { return Collections.unmodifiableList(fields); } + /** + * Returns all field names and their values, ordered the same way + * {@link #getFieldNames()} returns the names of the fields. + * + * @return All field names and values + */ + public Map getFields() { + Map fields = new LinkedHashMap(); + for (String field : getFieldNames()) { + fields.put(field, getField(field)); + } + return fields; + } + // // PRIVATE METHODS //