]> git.mxchange.org Git - jaddressbook-share-core.git/blobdiff - src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java
Continued:
[jaddressbook-share-core.git] / src / org / mxchange / jaddressbookshare / model / addressbook / shared / AddressbookShare.java
index 23bc52fdaee321b5a03e1541a2d176dc4711822e..5c9fda4bca9cd6c96984cbccc416eb950148a785 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 - 2018 Free Software Foundation
+ * Copyright (C) 2016 - 2020 Free Software Foundation
  *
  * 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
@@ -36,7 +36,7 @@ import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 import org.mxchange.jaddressbook.model.addressbook.Addressbook;
 import org.mxchange.jaddressbook.model.addressbook.UserAddressbook;
-import org.mxchange.jcoreee.utils.Comparables;
+import org.mxchange.jcoreutils.Comparables;
 import org.mxchange.jusercore.model.user.LoginUser;
 import org.mxchange.jusercore.model.user.User;
 
@@ -80,8 +80,15 @@ public class AddressbookShare implements ShareableAddressbook {
         */
        @Basic (optional = false)
        @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "share_created", nullable = false, updatable = false)
-       private Date shareCreated;
+       @Column (name = "share_entry_created", updatable = false, nullable = false)
+       private Date shareEntryCreated;
+
+       /**
+        * When this share has been updated
+        */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "share_entry_updated", insertable = false, nullable = false)
+       private Date shareEntryUpdated;
 
        /**
         * Id number
@@ -120,7 +127,7 @@ public class AddressbookShare implements ShareableAddressbook {
         * @param sharee      User sharee instance
         */
        public AddressbookShare (final Addressbook addressbook, final User sharee) {
-               // Call default constructor
+               // Invoke default constructor
                this();
 
                // Check all conditions
@@ -159,7 +166,7 @@ public class AddressbookShare implements ShareableAddressbook {
                if (null == shareableAddressbook) {
                        // Should not happen
                        throw new NullPointerException("shareableAddressbook is null"); //NOI18N
-               } else if (Objects.equals(this, shareableAddressbook)) {
+               } else if (shareableAddressbook.equals(this)) {
                        // Same object
                        return 0;
                }
@@ -171,8 +178,7 @@ public class AddressbookShare implements ShareableAddressbook {
                        // ... next sharer
                        this.getShareUserOwner().compareTo(shareableAddressbook.getShareUserOwner()),
                        // ... next sharee
-                       this.getShareUserSharee().compareTo(shareableAddressbook.getShareUserSharee()),
-               };
+                       this.getShareUserSharee().compareTo(shareableAddressbook.getShareUserSharee()),};
 
                // Check all values
                final int comparison = Comparables.checkAll(comparators);
@@ -193,10 +199,12 @@ public class AddressbookShare implements ShareableAddressbook {
 
                if (!Objects.equals(this.getShareAddressbook(), other.getShareAddressbook())) {
                        return false;
-               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
+               } else if (!Objects.equals(this.getShareId(), other.getShareId())) {
                        return false;
                } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
                        return false;
+               } else if (!Objects.equals(this.getShareUserSharee(), other.getShareUserSharee())) {
+                       return false;
                }
 
                return Objects.equals(this.getShareUserSharee(), other.getShareUserSharee());
@@ -214,14 +222,26 @@ public class AddressbookShare implements ShareableAddressbook {
 
        @Override
        @SuppressWarnings ("ReturnOfDateField")
-       public Date getShareCreated () {
-               return this.shareCreated;
+       public Date getShareEntryCreated () {
+               return this.shareEntryCreated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setShareEntryCreated (final Date shareEntryCreated) {
+               this.shareEntryCreated = shareEntryCreated;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getShareEntryUpdated () {
+               return this.shareEntryUpdated;
        }
 
        @Override
        @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setShareCreated (final Date shareCreated) {
-               this.shareCreated = shareCreated;
+       public void setShareEntryUpdated (final Date shareEntryUpdated) {
+               this.shareEntryUpdated = shareEntryUpdated;
        }
 
        @Override
@@ -259,6 +279,7 @@ public class AddressbookShare implements ShareableAddressbook {
                int hash = 7;
 
                hash = 19 * hash + Objects.hashCode(this.getShareAddressbook());
+               hash = 19 * hash + Objects.hashCode(this.getShareId());
                hash = 19 * hash + Objects.hashCode(this.getShareUserOwner());
                hash = 19 * hash + Objects.hashCode(this.getShareUserSharee());