X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FProfile.java;h=72901b31c9a818860dbc6520e07dfca48e5b9997;hb=90c85f39570270b879e2d3020fe95231410f57c6;hp=eeb04a41b31ccce6fcc76b43ee2d2ae2b8662fd0;hpb=549b1013740e7a95b5ab8ccb0f97f419a0dedb19;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 eeb04a4..72901b3 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -18,13 +18,16 @@ package net.pterodactylus.sone.data; /** - * A profile stores personal information about a {@link User}. All information + * A profile stores personal information about a {@link Sone}. All information * is optional and can be {@code null}. * * @author David ‘Bombe’ Roden */ public class Profile { + /** Whether the profile was modified. */ + private boolean modified; + /** The first name. */ private String firstName; @@ -34,6 +37,15 @@ public class Profile { /** The last name. */ private String lastName; + /** The day of the birth date. */ + private Integer birthDay; + + /** The month of the birth date. */ + private Integer birthMonth; + + /** The year of the birth date. */ + private Integer birthYear; + /** * Creates a new empty profile. */ @@ -48,9 +60,15 @@ public class Profile { * The profile to copy */ public Profile(Profile profile) { + if (profile == null) { + return; + } this.firstName = profile.firstName; this.middleName = profile.middleName; this.lastName = profile.lastName; + this.birthDay = profile.birthDay; + this.birthMonth = profile.birthMonth; + this.birthYear = profile.birthYear; } // @@ -58,6 +76,18 @@ public class Profile { // /** + * 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 @@ -71,9 +101,12 @@ public class Profile { * * @param firstName * The first name to set + * @return This profile (for method chaining) */ - public void setFirstName(String firstName) { + public Profile setFirstName(String firstName) { + modified |= ((firstName != null) && (!firstName.equals(this.firstName))) || (this.firstName != null); this.firstName = firstName; + return this; } /** @@ -90,9 +123,12 @@ public class Profile { * * @param middleName * The middle name to set + * @return This profile (for method chaining) */ - public void setMiddleName(String middleName) { + public Profile setMiddleName(String middleName) { + modified |= ((middleName != null) && (!middleName.equals(this.middleName))) || (this.middleName != null); this.middleName = middleName; + return this; } /** @@ -109,9 +145,78 @@ public class Profile { * * @param lastName * The last name to set + * @return This profile (for method chaining) */ - public void setLastName(String lastName) { + public Profile setLastName(String lastName) { + modified |= ((lastName != null) && (!lastName.equals(this.lastName))) || (this.lastName != null); this.lastName = lastName; + return this; + } + + /** + * Returns the day of the birth date. + * + * @return The day of the birth date (from 1 to 31) + */ + public Integer getBirthDay() { + return birthDay; + } + + /** + * Sets the day of the birth date. + * + * @param birthDay + * The day of the birth date (from 1 to 31) + * @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; + } + + /** + * Returns the month of the birth date. + * + * @return The month of the birth date (from 1 to 12) + */ + public Integer getBirthMonth() { + return birthMonth; + } + + /** + * Sets the month of the birth date. + * + * @param birthMonth + * The month of the birth date (from 1 to 12) + * @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; + } + + /** + * Returns the year of the birth date. + * + * @return The year of the birth date + */ + public Integer getBirthYear() { + return birthYear; + } + + /** + * Sets the year of the birth date. + * + * @param birthYear + * The year of the birth date + * @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; } }