From 9fda7311f84f9ab5692213f5d6fc9903dedf86f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Oct 2010 06:47:14 +0200 Subject: [PATCH] =?utf8?q?Add=20=E2=80=9Cis=20modified=E2=80=9D=20flag.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/data/Profile.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; } -- 2.7.4