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 volatile boolean modified;
31 /** The first name. */
32 private volatile String firstName;
34 /** The middle name(s). */
35 private volatile String middleName;
38 private volatile String lastName;
40 /** The day of the birth date. */
41 private volatile Integer birthDay;
43 /** The month of the birth date. */
44 private volatile Integer birthMonth;
46 /** The year of the birth date. */
47 private volatile Integer birthYear;
50 * Creates a new empty profile.
57 * Creates a copy of a profile.
62 public Profile(Profile profile) {
63 if (profile == null) {
66 this.firstName = profile.firstName;
67 this.middleName = profile.middleName;
68 this.lastName = profile.lastName;
69 this.birthDay = profile.birthDay;
70 this.birthMonth = profile.birthMonth;
71 this.birthYear = profile.birthYear;
79 * Returns whether this profile was modified after creation. To clear the
80 * “is modified” flag you need to create a new profile from this one using
81 * the {@link #Profile(Profile)} constructor.
83 * @return {@code true} if this profile was modified after creation,
84 * {@code false} otherwise
86 public boolean isModified() {
91 * Returns the first name.
93 * @return The first name
95 public String getFirstName() {
100 * Sets the first name.
103 * The first name to set
104 * @return This profile (for method chaining)
106 public Profile setFirstName(String firstName) {
107 modified |= ((firstName != null) && (!firstName.equals(this.firstName))) || (this.firstName != null);
108 this.firstName = firstName;
113 * Returns the middle name(s).
115 * @return The middle name
117 public String getMiddleName() {
122 * Sets the middle name.
125 * The middle name to set
126 * @return This profile (for method chaining)
128 public Profile setMiddleName(String middleName) {
129 modified |= ((middleName != null) && (!middleName.equals(this.middleName))) || (this.middleName != null);
130 this.middleName = middleName;
135 * Returns the last name.
137 * @return The last name
139 public String getLastName() {
144 * Sets the last name.
147 * The last name to set
148 * @return This profile (for method chaining)
150 public Profile setLastName(String lastName) {
151 modified |= ((lastName != null) && (!lastName.equals(this.lastName))) || (this.lastName != null);
152 this.lastName = lastName;
157 * Returns the day of the birth date.
159 * @return The day of the birth date (from 1 to 31)
161 public Integer getBirthDay() {
166 * Sets the day of the birth date.
169 * The day of the birth date (from 1 to 31)
170 * @return This profile (for method chaining)
172 public Profile setBirthDay(Integer birthDay) {
173 modified |= ((birthDay != null) && (!birthDay.equals(this.birthDay))) || (this.birthDay != null);
174 this.birthDay = birthDay;
179 * Returns the month of the birth date.
181 * @return The month of the birth date (from 1 to 12)
183 public Integer getBirthMonth() {
188 * Sets the month of the birth date.
191 * The month of the birth date (from 1 to 12)
192 * @return This profile (for method chaining)
194 public Profile setBirthMonth(Integer birthMonth) {
195 modified |= ((birthMonth != null) && (!birthMonth.equals(this.birthMonth))) || (this.birthMonth != null);
196 this.birthMonth = birthMonth;
201 * Returns the year of the birth date.
203 * @return The year of the birth date
205 public Integer getBirthYear() {
210 * Sets the year of the birth date.
213 * The year of the birth date
214 * @return This profile (for method chaining)
216 public Profile setBirthYear(Integer birthYear) {
217 modified |= ((birthYear != null) && (!birthYear.equals(this.birthYear))) || (this.birthYear != null);
218 this.birthYear = birthYear;