From: David ‘Bombe’ Roden Date: Thu, 14 Oct 2010 04:47:14 +0000 (+0200) Subject: Add “is modified” flag. X-Git-Tag: 0.1-RC1~442 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9fda7311f84f9ab5692213f5d6fc9903dedf86f8;p=Sone.git Add “is modified” flag. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index eeb04a4..d82195c 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -25,6 +25,9 @@ package net.pterodactylus.sone.data; */ public class Profile { + /** Whether the profile was modified. */ + private boolean modified; + /** The first name. */ private String firstName; @@ -58,6 +61,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 @@ -73,6 +88,7 @@ public class Profile { * The first name to set */ public void setFirstName(String firstName) { + modified |= ((firstName != null) && (!firstName.equals(this.firstName))) || (this.firstName != null); this.firstName = firstName; } @@ -92,6 +108,7 @@ public class Profile { * The middle name to set */ public void setMiddleName(String middleName) { + modified |= ((middleName != null) && (!middleName.equals(this.middleName))) || (this.middleName != null); this.middleName = middleName; } @@ -111,6 +128,7 @@ public class Profile { * The last name to set */ public void setLastName(String lastName) { + modified |= ((lastName != null) && (!lastName.equals(this.lastName))) || (this.lastName != null); this.lastName = lastName; }