From 91f1daadb3bfff02b4a2d739bbc25dacd3f32971 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 26 Apr 2020 18:23:55 +0200 Subject: [PATCH] Continued: - compare all (except timestamps) properties of entities, again including primary key - added "updated" timestamp MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../addressbook/shared/AddressbookShare.java | 39 ++++++++++++++----- .../shared/ShareableAddressbook.java | 26 ++++++++++--- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java b/src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java index fa509dd..5c9fda4 100644 --- a/src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java +++ b/src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java @@ -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 @@ -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()); diff --git a/src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java b/src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java index 9f85bd0..3fb51bb 100644 --- a/src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java +++ b/src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java @@ -85,18 +85,32 @@ public interface ShareableAddressbook extends Comparable, void setShareUserSharee (final User shareUserSharer); /** - * Getter for share creation timestamp + * Getter for share created timestamp *

- * @return Share creation timestamp + * @return Share created timestamp */ - Date getShareCreated (); + Date getShareEntryCreated (); /** - * Setter for share creation timestamp + * Setter for share created timestamp *

- * @param shareCreated Share creation timestamp + * @param shareCreated Share created timestamp */ - void setShareCreated (final Date shareCreated); + void setShareEntryCreated (final Date shareCreated); + + /** + * Getter for share updated timestamp + *

+ * @return Share updated timestamp + */ + Date getShareEntryUpdated (); + + /** + * Setter for share updated timestamp + *

+ * @param shareUpdated Share updated timestamp + */ + void setShareEntryUpdated (final Date shareUpdated); @Override boolean equals (final Object object); -- 2.39.5