2 * FreenetSone - Profile.java - Copyright Ā© 2010 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.data;
21 * A profile stores personal information about a {@link Sone}. All information
22 * is optional and can be {@code null}.
24 * @author <a href="mailto:bombe@pterodactylus.net">David āBombeā Roden</a>
26 public class Profile {
28 /** Whether the profile was modified. */
29 private boolean modified;
31 /** The first name. */
32 private String firstName;
34 /** The middle name(s). */
35 private String middleName;
38 private String lastName;
41 * Creates a new empty profile.
48 * Creates a copy of a profile.
53 public Profile(Profile profile) {
54 if (profile == null) {
57 this.firstName = profile.firstName;
58 this.middleName = profile.middleName;
59 this.lastName = profile.lastName;
67 * Returns whether this profile was modified after creation. To clear the
68 * āis modifiedā flag you need to create a new profile from this one using
69 * the {@link #Profile(Profile)} constructor.
71 * @return {@code true} if this profile was modified after creation,
72 * {@code false} otherwise
74 public boolean isModified() {
79 * Returns the first name.
81 * @return The first name
83 public String getFirstName() {
88 * Sets the first name.
91 * The first name to set
92 * @return This profile (for method chaining)
94 public Profile setFirstName(String firstName) {
95 modified |= ((firstName != null) && (!firstName.equals(this.firstName))) || (this.firstName != null);
96 this.firstName = firstName;
101 * Returns the middle name(s).
103 * @return The middle name
105 public String getMiddleName() {
110 * Sets the middle name.
113 * The middle name to set
114 * @return This profile (for method chaining)
116 public Profile setMiddleName(String middleName) {
117 modified |= ((middleName != null) && (!middleName.equals(this.middleName))) || (this.middleName != null);
118 this.middleName = middleName;
123 * Returns the last name.
125 * @return The last name
127 public String getLastName() {
132 * Sets the last name.
135 * The last name to set
136 * @return This profile (for method chaining)
138 public Profile setLastName(String lastName) {
139 modified |= ((lastName != null) && (!lastName.equals(this.lastName))) || (this.lastName != null);
140 this.lastName = lastName;