You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2024/05/25 14:15:34 UTC
(causeway-app-petclinic) 01/04: adds PetOwner#getDaysSinceLastVisit derived property
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/causeway-app-petclinic.git
commit 0eec2602e96dd708897ddc76b8c12edaa706ebc5
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Sat May 25 14:45:42 2024 +0100
adds PetOwner#getDaysSinceLastVisit derived property
---
.../domainapp/modules/petowner/dom/petowner/PetOwner.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java b/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
index 29a659e..decd769 100644
--- a/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
+++ b/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
@@ -2,7 +2,9 @@ package domainapp.modules.petowner.dom.petowner;
import java.time.LocalTime;
import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
import java.util.Comparator;
+import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Named;
@@ -185,6 +187,15 @@ public class PetOwner implements Comparable<PetOwner>, CalendarEventable {
private java.time.LocalDate lastVisit;
+ @Property
+ @PropertyLayout(fieldSetId = LayoutConstants.FieldSetId.DETAILS, sequence = "3.1")
+ public Long getDaysSinceLastVisit() {
+ return getLastVisit() != null
+ ? ChronoUnit.DAYS.between(getLastVisit(), clockService.getClock().nowAsLocalDate())
+ : null;
+ }
+
+
@Override
public String getCalendarName() {
return "Last checked-in";