From: Roland Haeder Date: Thu, 15 Oct 2015 17:42:11 +0000 (+0200) Subject: Implemented isOwnAddressbook() and isOtherAddressbook() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e1ce24bc1d5f5e6859415e9df5004e9d4e810e12;p=jfinancials-war.git Implemented isOwnAddressbook() and isOtherAddressbook() --- diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java index b97648e6..1c66acdf 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java @@ -22,6 +22,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.GregorianCalendar; import java.util.List; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.annotation.PostConstruct; @@ -372,6 +373,24 @@ public class AddressbookWebBean implements AddressbookWebController { return isFound; } + @Override + public boolean isOtherAddressbook () { + // Just call the other method and invert it + return (!this.isOwnAddressbook()); + } + + @Override + public boolean isOwnAddressbook () { + // Is the user logged in? + if (!this.loginController.isUserLoggedIn()) { + // No, then no own address book + return false; + } + + // Is same user? + return Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser()); + } + /** * Initializes the user user's address book list */ diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java index 96546cb7..285ce793 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java @@ -171,4 +171,21 @@ public interface AddressbookWebController extends Serializable { * @param event */ void afterLoginEvent (final UserLoggedInEvent event); + + /** + * Checks if the user is logged in and if so if it matches the current + * address book owner. + *

+ * @return Whether the owner matches currently logged-in user + */ + boolean isOwnAddressbook (); + + /** + * Checks if the owner of the current address book is NOT matching the + * logged-in user. + *

+ * @return Whether the user does NOT match + */ + boolean isOtherAddressbook (); + }