From: Roland Haeder <roland@mxchange.org>
Date: Tue, 13 Oct 2015 13:07:18 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e0313e717508afb54bfceb807611864489344b70;p=jbonuscard-lib.git

Continued:
- added POJO/POJI for address book sharing
- added equals()/hashCode()
- updated jar(s)
Signed-off-by:Roland Häder <roland@mxchange.org>
---

diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar
index 61f8e0f..f819915 100644
Binary files a/lib/jcontacts-business-core.jar and b/lib/jcontacts-business-core.jar differ
diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar
index 680b3d1..a135b3e 100644
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
diff --git a/lib/jcountry-core.jar b/lib/jcountry-core.jar
index 049ef5f..7166776 100644
Binary files a/lib/jcountry-core.jar and b/lib/jcountry-core.jar differ
diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar
index 5fc3762..c2ea571 100644
Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ
diff --git a/lib/juser-core.jar b/lib/juser-core.jar
index bf521fb..b5427c7 100644
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
diff --git a/src/org/mxchange/addressbook/model/addressbook/Addressbook.java b/src/org/mxchange/addressbook/model/addressbook/Addressbook.java
index 9b03baa..fab8526 100644
--- a/src/org/mxchange/addressbook/model/addressbook/Addressbook.java
+++ b/src/org/mxchange/addressbook/model/addressbook/Addressbook.java
@@ -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 ();
 }
diff --git a/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java b/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java
index 95496f1..2ddd1cb 100644
--- a/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java
+++ b/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java
@@ -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;
+	}
 }
diff --git a/src/org/mxchange/addressbook/model/addressbook/entry/AddressbookEntry.java b/src/org/mxchange/addressbook/model/addressbook/entry/AddressbookEntry.java
index 930fbb3..fb257dc 100644
--- a/src/org/mxchange/addressbook/model/addressbook/entry/AddressbookEntry.java
+++ b/src/org/mxchange/addressbook/model/addressbook/entry/AddressbookEntry.java
@@ -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 ();
 }
diff --git a/src/org/mxchange/addressbook/model/addressbook/entry/UserAddressbookEntry.java b/src/org/mxchange/addressbook/model/addressbook/entry/UserAddressbookEntry.java
index 4ad8484..968bbbb 100644
--- a/src/org/mxchange/addressbook/model/addressbook/entry/UserAddressbookEntry.java
+++ b/src/org/mxchange/addressbook/model/addressbook/entry/UserAddressbookEntry.java
@@ -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
index 0000000..8777d91
--- /dev/null
+++ b/src/org/mxchange/addressbook/model/addressbook/shared/AddressbookShare.java
@@ -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
index 0000000..43da044
--- /dev/null
+++ b/src/org/mxchange/addressbook/model/addressbook/shared/ShareableAddressbook.java
@@ -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 ();
+}