diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java index c5ae067dc..f6a0f363b 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java @@ -134,10 +134,8 @@ public class Owner extends Person { public Pet getPet(String name, boolean ignoreNew) { for (Pet pet : getPets()) { String compName = pet.getName(); - if (compName != null && compName.equalsIgnoreCase(name)) { - if (!ignoreNew || !pet.isNew()) { - return pet; - } + if (compName != null && compName.equalsIgnoreCase(name) && (!ignoreNew || !pet.isNew())) { + return pet; } } return null; @@ -172,4 +170,4 @@ public class Owner extends Person { pet.addVisit(visit); } -} +} \ No newline at end of file