]> git.mxchange.org Git - jaddressbook-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 26 Apr 2020 16:17:52 +0000 (18:17 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Apr 2020 16:17:52 +0000 (18:17 +0200)
- added "entry updated" timestamps
- compare all entity properties in equals()/hashCode() methods

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java
src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java
src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java
src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java

index b19c42604bad09e3dbc0829dfdf719a4c8280f66..2123afadaad39fa3ca1b07f3ab01756539a30634 100644 (file)
@@ -43,19 +43,33 @@ public interface Addressbook extends Comparable<Addressbook>, Serializable {
        void setAddressbookId (final Long addressbookId);
 
        /**
-        * Getter for addressbook creation timestamp
+        * Getter for addressbook created timestamp
         * <p>
-        * @return Addressbook creation timestamp
+        * @return Addressbook created timestamp
         */
        Date getAddressbookCreated ();
 
        /**
-        * Setter for addressbook creation timestamp
+        * Setter for addressbook created timestamp
         * <p>
-        * @param addressbookCreated Addressbook creation timestamp
+        * @param addressbookCreated Addressbook created timestamp
         */
        void setAddressbookCreated (final Date addressbookCreated);
 
+       /**
+        * Getter for addressbook updated timestamp
+        * <p>
+        * @return Addressbook updated timestamp
+        */
+       Date getAddressbookUpdated ();
+
+       /**
+        * Setter for addressbook updated timestamp
+        * <p>
+        * @param addressbookUpdated Addressbook updated timestamp
+        */
+       void setAddressbookUpdated (final Date addressbookUpdated);
+
        /**
         * Getter for addressbook's name
         * <p>
index b36989b8cee50abdc710c2faf394879580afd387..252d46e6ca29ce3d95e5de9cf6c8c4b5e518f5c0 100644 (file)
@@ -69,7 +69,7 @@ public class UserAddressbook implements Addressbook {
         */
        @Basic (optional = false)
        @Temporal (value = TemporalType.TIMESTAMP)
-       @Column (name = "addressbook_created", nullable = false, updatable = false)
+       @Column (name = "addressbook_created", updatable = false, nullable = false)
        private Date addressbookCreated;
 
        /**
@@ -109,6 +109,13 @@ public class UserAddressbook implements Addressbook {
        @Column (name = "addressbook_status", nullable = false, length = 10)
        private AddressbokStatus addressbookStatus;
 
+       /**
+        * When this address book has been created
+        */
+       @Temporal (value = TemporalType.TIMESTAMP)
+       @Column (name = "addressbook_updated", insertable = false, nullable = false)
+       private Date addressbookUpdated;
+
        /**
         * Connection to "users" table
         */
@@ -175,7 +182,15 @@ public class UserAddressbook implements Addressbook {
 
                final Addressbook other = (Addressbook) object;
 
-               if (!Objects.equals(this.getAddressbookName(), other.getAddressbookName())) {
+               if (!Objects.equals(this.getAddressbookId(), other.getAddressbookId())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookLastLocked(), other.getAddressbookLastLocked())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookLastLockedReason(), other.getAddressbookLastLockedReason())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookName(), other.getAddressbookName())) {
+                       return false;
+               } else if (!Objects.equals(this.getAddressbookStatus(), other.getAddressbookStatus())) {
                        return false;
                } else if (!Objects.equals(this.getAddressbookUser(), other.getAddressbookUser())) {
                        return false;
@@ -248,6 +263,18 @@ public class UserAddressbook implements Addressbook {
                this.addressbookStatus = addressbookStatus;
        }
 
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getAddressbookUpdated () {
+               return this.addressbookUpdated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setAddressbookUpdated (final Date addressbookUpdated) {
+               this.addressbookUpdated = addressbookUpdated;
+       }
+
        @Override
        public User getAddressbookUser () {
                return this.addressbookUser;
@@ -262,7 +289,11 @@ public class UserAddressbook implements Addressbook {
        public int hashCode () {
                int hash = 7;
 
+               hash = 59 * hash + Objects.hashCode(this.getAddressbookId());
+               hash = 59 * hash + Objects.hashCode(this.getAddressbookLastLocked());
+               hash = 59 * hash + Objects.hashCode(this.getAddressbookLastLockedReason());
                hash = 59 * hash + Objects.hashCode(this.getAddressbookName());
+               hash = 59 * hash + Objects.hashCode(this.getAddressbookStatus());
                hash = 59 * hash + Objects.hashCode(this.getAddressbookUser());
 
                return hash;
index f5bb4944df19a2aaa2b576257f91f1370d2c22f4..b79d3eaf79720fd5744ba1ec0283f9cb24c3216d 100644 (file)
@@ -71,6 +71,20 @@ public interface AddressbookEntry extends Comparable<AddressbookEntry>, Serializ
         */
        void setAddressbookEntryCreated (final Date addressbookEntryCreated);
 
+       /**
+        * Getter for entry updated timestamp
+        * <p>
+        * @return Entry updated timestamp
+        */
+       Date getAddressbookEntryUpdated ();
+
+       /**
+        * Setter for entry updated timestamp
+        * <p>
+        * @param addressbookEntryUpdated Entry updated timestamp
+        */
+       void setAddressbookEntryUpdated (final Date addressbookEntryUpdated);
+
        /**
         * Getter for private contact
         * <p>
index 786dfa57b788aa698a86967efc41376847f67b5a..4d1a57d7fd4287ca0769f7cb349ba7242e6a4dbf 100644 (file)
@@ -74,7 +74,7 @@ public class UserAddressbookEntry implements AddressbookEntry {
         */
        @Basic (optional = false)
        @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "entry_created", nullable = false, updatable = false)
+       @Column (name = "entry_created", updatable = false, nullable = false)
        private Date addressbookEntryCreated;
 
        /**
@@ -92,6 +92,13 @@ public class UserAddressbookEntry implements AddressbookEntry {
        @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH)
        private Contact addressbookEntryPrivateContact;
 
+       /**
+        * When this address book entry has been updated
+        */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "entry_updated", insertable = false, nullable = false)
+       private Date addressbookEntryUpdated;
+
        /**
         * Connection to table "address books"
         */
@@ -139,6 +146,8 @@ public class UserAddressbookEntry implements AddressbookEntry {
 
                if (!Objects.equals(this.getAddressbookEntryBusinessBasicData(), other.getAddressbookEntryBusinessBasicData())) {
                        return false;
+               } else if (!Objects.equals(this.getAddressbookEntryId(), other.getAddressbookEntryId())) {
+                       return false;
                } else if (!Objects.equals(this.getAddressbookEntryPrivateContact(), other.getAddressbookEntryPrivateContact())) {
                        return false;
                } else if (!Objects.equals(this.getEntryAddressbook(), other.getEntryAddressbook())) {
@@ -190,6 +199,18 @@ public class UserAddressbookEntry implements AddressbookEntry {
                this.addressbookEntryPrivateContact = addressbookEntryPrivateContact;
        }
 
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getAddressbookEntryUpdated () {
+               return this.addressbookEntryUpdated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setAddressbookEntryUpdated (final Date addressbookEntryUpdated) {
+               this.addressbookEntryUpdated = addressbookEntryUpdated;
+       }
+
        @Override
        public Addressbook getEntryAddressbook () {
                return this.entryAddressbook;
@@ -205,6 +226,7 @@ public class UserAddressbookEntry implements AddressbookEntry {
                int hash = 3;
 
                hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessBasicData());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryId());
                hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
                hash = 19 * hash + Objects.hashCode(this.getEntryAddressbook());