*/
public class Profile {
+ /** Whether the profile was modified. */
+ private boolean modified;
+
/** The first name. */
private String firstName;
//
/**
+ * 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
* The first name to set
*/
public void setFirstName(String firstName) {
+ modified |= ((firstName != null) && (!firstName.equals(this.firstName))) || (this.firstName != null);
this.firstName = firstName;
}
* The middle name to set
*/
public void setMiddleName(String middleName) {
+ modified |= ((middleName != null) && (!middleName.equals(this.middleName))) || (this.middleName != null);
this.middleName = middleName;
}
* The last name to set
*/
public void setLastName(String lastName) {
+ modified |= ((lastName != null) && (!lastName.equals(this.lastName))) || (this.lastName != null);
this.lastName = lastName;
}