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 2026/04/09 10:57:32 UTC
(causeway-app-petclinic) tag tags/3.6.0/04-06-unique-pet-names-validation created (now ea4fe00)
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a change to tag tags/3.6.0/04-06-unique-pet-names-validation
in repository https://gitbox.apache.org/repos/asf/causeway-app-petclinic.git
at ea4fe00 (commit)
This tag includes the following new commits:
new ea4fe00 adds validation to check that each owner's pet has a different name
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(causeway-app-petclinic) 01/01: adds validation to check that each owner's pet has a different name
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to tag tags/3.6.0/04-06-unique-pet-names-validation
in repository https://gitbox.apache.org/repos/asf/causeway-app-petclinic.git
commit ea4fe001ba8505752577bdcd2dae4458aab7ec0f
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Sun May 26 14:16:45 2024 +0100
adds validation to check that each owner's pet has a different name
---
.../java/domainapp/modules/petowner/dom/petowner/PetOwner.java | 9 +++++++++
1 file changed, 9 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 0502a74..78341d4 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
@@ -4,6 +4,7 @@
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.Comparator;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
@@ -171,6 +172,14 @@ public PetOwner addPet(@PetName final String name) {
return this;
}
+ @MemberSupport
+ public String validate0AddPet(final String name) {
+ if (getPets().stream().anyMatch(x -> Objects.equals(x.getName(), name))) {
+ return "This owner already has a pet called '" + name + "'";
+ }
+ return null;
+ }
+
@Action(choicesFrom = "pets")
@ActionLayout(associateWith = "pets", sequence = "2")
public PetOwner removePet(@PetName final Pet pet) {