X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FProfile.java;h=242c96e4bde26b5371cf1b2a535bc15c14b8a559;hb=554a8f521027da73bd6519f3480b1ed70b108903;hp=255dacb21126fc1bc454540e91ab84a6d007a668;hpb=628936b67423d4e26d9c990ab1bb44ad788e5b3f;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 255dacb..242c96e 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -18,16 +18,30 @@ package net.pterodactylus.sone.data; /** - * A profile stores personal information about a {@link User}. + * 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; + + /** The middle name(s). */ + private String middleName; + + /** The last name. */ + private String lastName; + /** - * Creates a new profile. + * Creates a new empty profile. */ public Profile() { + /* do nothing. */ } /** @@ -37,6 +51,91 @@ public class Profile { * The profile to copy */ public Profile(Profile profile) { + this.firstName = profile.firstName; + this.middleName = profile.middleName; + this.lastName = profile.lastName; + } + + // + // ACCESSORS + // + + /** + * 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 + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the first name. + * + * @param firstName + * The first name to set + * @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; + } + + /** + * Returns the middle name(s). + * + * @return The middle name + */ + public String getMiddleName() { + return middleName; + } + + /** + * Sets the middle name. + * + * @param middleName + * The middle name to set + * @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; + } + + /** + * Returns the last name. + * + * @return The last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets the last name. + * + * @param lastName + * The last name to set + * @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; } }