From: Roland Häder Date: Sun, 26 Apr 2020 16:17:52 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2eb0bc6f19eb2607e01a396dc38b882a758c3514;p=jaddressbook-core.git Continued: - added "entry updated" timestamps - compare all entity properties in equals()/hashCode() methods Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java b/src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java index b19c426..2123afa 100644 --- a/src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java @@ -43,19 +43,33 @@ public interface Addressbook extends Comparable, Serializable { void setAddressbookId (final Long addressbookId); /** - * Getter for addressbook creation timestamp + * Getter for addressbook created timestamp *

- * @return Addressbook creation timestamp + * @return Addressbook created timestamp */ Date getAddressbookCreated (); /** - * Setter for addressbook creation timestamp + * Setter for addressbook created timestamp *

- * @param addressbookCreated Addressbook creation timestamp + * @param addressbookCreated Addressbook created timestamp */ void setAddressbookCreated (final Date addressbookCreated); + /** + * Getter for addressbook updated timestamp + *

+ * @return Addressbook updated timestamp + */ + Date getAddressbookUpdated (); + + /** + * Setter for addressbook updated timestamp + *

+ * @param addressbookUpdated Addressbook updated timestamp + */ + void setAddressbookUpdated (final Date addressbookUpdated); + /** * Getter for addressbook's name *

diff --git a/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java b/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java index b36989b..252d46e 100644 --- a/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java @@ -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; diff --git a/src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java b/src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java index f5bb494..b79d3ea 100644 --- a/src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java @@ -71,6 +71,20 @@ public interface AddressbookEntry extends Comparable, Serializ */ void setAddressbookEntryCreated (final Date addressbookEntryCreated); + /** + * Getter for entry updated timestamp + *

+ * @return Entry updated timestamp + */ + Date getAddressbookEntryUpdated (); + + /** + * Setter for entry updated timestamp + *

+ * @param addressbookEntryUpdated Entry updated timestamp + */ + void setAddressbookEntryUpdated (final Date addressbookEntryUpdated); + /** * Getter for private contact *

diff --git a/src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java b/src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java index 786dfa5..4d1a57d 100644 --- a/src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java @@ -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());