]> git.mxchange.org Git - addressbook-lib.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Tue, 13 Oct 2015 13:07:18 +0000 (15:07 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 13 Oct 2015 13:23:40 +0000 (15:23 +0200)
- added POJO/POJI for address book sharing
- added equals()/hashCode()
- updated jar(s)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcontacts-business-core.jar
lib/jcontacts-core.jar
lib/jcountry-core.jar
lib/jphone-core.jar
lib/juser-core.jar
src/org/mxchange/addressbook/model/addressbook/Addressbook.java
src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java
src/org/mxchange/addressbook/model/addressbook/entry/AddressbookEntry.java
src/org/mxchange/addressbook/model/addressbook/entry/UserAddressbookEntry.java
src/org/mxchange/addressbook/model/addressbook/shared/AddressbookShare.java [new file with mode: 0644]
src/org/mxchange/addressbook/model/addressbook/shared/ShareableAddressbook.java [new file with mode: 0644]

index 61f8e0faf43ac454ac2fb7dfc3cd569ea6b53492..f8199150d48ef526ec624f8f862b7cac07cde80c 100644 (file)
Binary files a/lib/jcontacts-business-core.jar and b/lib/jcontacts-business-core.jar differ
index 680b3d15b6eb6b3dff401aa9542f41578fb194ee..a135b3e153b7ed6f0b5f5d406f2306092bbb2e73 100644 (file)
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
index 049ef5f9ea049cecb9bb874ec9b9c5518d6aec4c..7166776ede488c2c9e08be75ae1f7ff182548993 100644 (file)
Binary files a/lib/jcountry-core.jar and b/lib/jcountry-core.jar differ
index 5fc37624f0e952d722990706c34aa17b065d2bef..c2ea571cf165c20b792f0bffd69afb5d0a49ba30 100644 (file)
Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ
index bf521fb34418443b4313045a38e41f3fc864b0b5..b5427c7ef70674cd0b86e5919c381741b38480b1 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 9b03baa7c33c9a5271140532da4bd6b6a7c5d42a..fab8526964416f1283b80f29e27abc07ddac7357 100644 (file)
@@ -97,4 +97,10 @@ public interface Addressbook extends Serializable {
         * @param addressbookUser Addressbook's user (owner)
         */
        public void setAddressbookUser (final User addressbookUser);
+
+       @Override
+       public boolean equals (final Object object);
+
+       @Override
+       public int hashCode ();
 }
index 95496f104b0b7703657ea7d0b62f135e9a9ea019..2ddd1cb1bf66cbc6c2aea258bcf51800645767f8 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.addressbook.model.addressbook;
 
 import java.util.Calendar;
+import java.util.Objects;
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
@@ -120,6 +121,25 @@ public class UserAddressbook implements Addressbook, Comparable<Addressbook> {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
 
+       @Override
+       public boolean equals (final Object object) {
+               if (object == null) {
+                       return false;
+               } else if (getClass() != object.getClass()) {
+                       return false;
+               }
+
+               final Addressbook other = (Addressbook) object;
+
+               if (!Objects.equals(this.getAddressbookName(), other.getAddressbookName())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookUser(), other.getAddressbookUser())) {
+                       return false;
+               }
+
+               return true;
+       }
+
        @Override
        public Calendar getAddressbookCreated () {
                return this.addressbookCreated;
@@ -169,4 +189,12 @@ public class UserAddressbook implements Addressbook, Comparable<Addressbook> {
        public void setAddressbookUser (final User addressbookUser) {
                this.addressbookUser = addressbookUser;
        }
+
+       @Override
+       public int hashCode () {
+               int hash = 7;
+               hash = 59 * hash + Objects.hashCode(this.getAddressbookName());
+               hash = 59 * hash + Objects.hashCode(this.getAddressbookUser());
+               return hash;
+       }
 }
index 930fbb342711c713933f4b74b39b061ad8657def..fb257dc81f4a3eca91b127cdba5842f000b5a8a3 100644 (file)
@@ -129,4 +129,9 @@ public interface AddressbookEntry extends Serializable {
         */
        public void setAddressbookId (final Addressbook addressbookId);
 
+       @Override
+       public boolean equals (final Object object);
+
+       @Override
+       public int hashCode ();
 }
index 4ad8484b86d74b945d1b1e94a74c0ccaea928ec4..968bbbb9ca60a753403f550f465ce146464912f2 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.addressbook.model.addressbook.entry;
 
 import java.util.Calendar;
+import java.util.Objects;
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
@@ -115,6 +116,31 @@ public class UserAddressbookEntry implements AddressbookEntry, Comparable<Addres
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
 
+       @Override
+       public boolean equals (final Object object) {
+               if (object == null) {
+                       return false;
+               } else if (getClass() != object.getClass()) {
+                       return false;
+               }
+
+               final AddressbookEntry other = (AddressbookEntry) object;
+
+               if (!Objects.equals(this.getAddressbookEntryBusinessContact(), other.getAddressbookEntryBusinessContact())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookEntryPrivateContact(), other.getAddressbookEntryPrivateContact())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookEntryUserOwner(), other.getAddressbookEntryUserOwner())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookEntryUserSharer(), other.getAddressbookEntryUserSharer())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookId(), other.getAddressbookId())) {
+                       return false;
+               }
+
+               return true;
+       }
+
        @Override
        public BusinessContact getAddressbookEntryBusinessContact () {
                return this.addressbookEntryBusinessContact;
@@ -185,4 +211,15 @@ public class UserAddressbookEntry implements AddressbookEntry, Comparable<Addres
                this.addressbookId = addressbookId;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 3;
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessContact());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryUserOwner());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryUserSharer());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookId());
+               return hash;
+       }
+
 }
diff --git a/src/org/mxchange/addressbook/model/addressbook/shared/AddressbookShare.java b/src/org/mxchange/addressbook/model/addressbook/shared/AddressbookShare.java
new file mode 100644 (file)
index 0000000..8777d91
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.model.addressbook.shared;
+
+import java.util.Objects;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import org.mxchange.addressbook.model.addressbook.Addressbook;
+import org.mxchange.addressbook.model.addressbook.UserAddressbook;
+import org.mxchange.jusercore.model.user.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJO for sharing address books with other users
+ * <p>
+ * @author Roland Haeder
+ */
+@Entity (name = "addressbook_shares")
+@Table (name = "addressbook_shares")
+public class AddressbookShare implements ShareableAddressbook, Comparable<ShareableAddressbook> {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 167_889_678_177_691_690L;
+
+       /**
+        * Id number
+        */
+       @Id
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       @Column (name = "share_id", length = 20, nullable = false, updatable = false)
+       private Long shareId;
+
+       /**
+        * Address book this share is for
+        */
+       @JoinColumn (name = "share_addressbook_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = UserAddressbook.class, cascade = CascadeType.ALL, optional = false)
+       private Addressbook shareAddressbook;
+
+       /**
+        * User who is giving the share (for his/her address book)
+        */
+       @JoinColumn (name = "share_owner_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.ALL, optional = false)
+       private User shareUserOwner;
+
+       /**
+        * User the address book is shared with
+        */
+       @JoinColumn (name = "share_sharee_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.ALL, optional = false)
+       private User shareUserSharee;
+
+       @Override
+       public int compareTo (final ShareableAddressbook share) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public boolean equals (final Object object) {
+               if (object == null) {
+                       return false;
+               } else if (getClass() != object.getClass()) {
+                       return false;
+               }
+
+               final ShareableAddressbook other = (ShareableAddressbook) object;
+
+               if (!Objects.equals(this.getShareAddressbook(), other.getShareAddressbook())) {
+                       return false;
+               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
+                       return false;
+               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
+                       return false;
+               }
+
+               return Objects.equals(this.getShareUserSharee(), other.getShareUserSharee());
+       }
+
+       @Override
+       public Addressbook getShareAddressbook () {
+               return this.shareAddressbook;
+       }
+
+       @Override
+       public void setShareAddressbook (final Addressbook shareAddressbook) {
+               this.shareAddressbook = shareAddressbook;
+       }
+
+       @Override
+       public Long getShareId () {
+               return this.shareId;
+       }
+
+       @Override
+       public void setShareId (final Long shareId) {
+               this.shareId = shareId;
+       }
+
+       @Override
+       public User getShareUserOwner () {
+               return this.shareUserOwner;
+       }
+
+       @Override
+       public void setShareUserOwner (final User shareUserOwner) {
+               this.shareUserOwner = shareUserOwner;
+       }
+
+       @Override
+       public User getShareUserSharee () {
+               return this.shareUserSharee;
+       }
+
+       @Override
+       public void setShareUserSharee (final User shareUserSharee) {
+               this.shareUserSharee = shareUserSharee;
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 7;
+               hash = 19 * hash + Objects.hashCode(this.getShareAddressbook());
+               hash = 19 * hash + Objects.hashCode(this.getShareUserOwner());
+               hash = 19 * hash + Objects.hashCode(this.getShareUserSharee());
+               return hash;
+       }
+}
diff --git a/src/org/mxchange/addressbook/model/addressbook/shared/ShareableAddressbook.java b/src/org/mxchange/addressbook/model/addressbook/shared/ShareableAddressbook.java
new file mode 100644 (file)
index 0000000..43da044
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.model.addressbook.shared;
+
+import java.io.Serializable;
+import org.mxchange.addressbook.model.addressbook.Addressbook;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJI for shared address books
+ * <p>
+ * @author Roland Haeder
+ */
+public interface ShareableAddressbook extends Serializable {
+
+       /**
+        * Getter for shared address book instance
+        * <p>
+        * @return Shared address book instance
+        */
+       public Addressbook getShareAddressbook ();
+
+       /**
+        * Setter for shared address book instance
+        * <p>
+        * @param shareAddressbook Shared address book instance
+        */
+       public void setShareAddressbook (final Addressbook shareAddressbook);
+
+       /**
+        * Getter for id number
+        * <p>
+        * @return Id number
+        */
+       public Long getShareId ();
+
+       /**
+        * Setter for id number
+        * <p>
+        * @param shareId Id number
+        */
+       public void setShareId (final Long shareId);
+
+       /**
+        * Getter for address book owner instance
+        * <p>
+        * @return Address book owner instance
+        */
+       public User getShareUserOwner ();
+
+       /**
+        * Setter for address book owner instance
+        * <p>
+        * @param shareUserOwner Address book owner instance
+        */
+       public void setShareUserOwner (final User shareUserOwner);
+
+       /**
+        * Getter for address book sharee instance
+        * <p>
+        * @return Address book sharee instance
+        */
+       public User getShareUserSharee ();
+
+       /**
+        * Setter for address book sharee instance
+        * <p>
+        * @param shareUserSharer Address book sharee instance
+        */
+       public void setShareUserSharee (final User shareUserSharer);
+
+       @Override
+       public boolean equals (final Object object);
+
+       @Override
+       public int hashCode ();
+}