From 1b3228426bbf7f3511f299a58099040e66d3817b Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Sun, 16 Oct 2022 14:50:25 +0200 Subject: [PATCH] GH-44 - ApplicationModules.verify() now returns itself. --- .../modulith/model/ApplicationModules.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java b/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java index 230822ad..f89ec3d7 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java @@ -121,8 +121,8 @@ public class ApplicationModules implements Iterable { /** * Creates a new {@link ApplicationModules} relative to the given modulith type, a * {@link ApplicationModuleDetectionStrategy} and a {@link DescribedPredicate} which types and packages to ignore. - * Will inspect the {@link Modulith} and {@link Modulithic} annotations on the class given for advanced - * customizations of the module setup. + * Will inspect the {@link Modulith} and {@link Modulithic} annotations on the class given for advanced customizations + * of the module setup. * * @param modulithType must not be {@literal null}. * @param detection must not be {@literal null}. @@ -280,10 +280,15 @@ public class ApplicationModules implements Iterable { .findFirst(); } - public void verify() { + /** + * Execute all verifications to be applied, unless the verifcation has been executed before. + * + * @return will never be {@literal null}. + */ + public ApplicationModules verify() { if (verified) { - return; + return this; } Violations violations = detectViolations(); @@ -291,8 +296,17 @@ public class ApplicationModules implements Iterable { this.verified = true; violations.throwIfPresent(); + + return this; } + /** + * Executes all verifications to be applied and returns {@link Violations} if any occured. Will always execute the + * verifications in contrast to {@link #verify()} which just runs once. + * + * @return will never be {@literal null}. + * @see Violations#throwIfPresent() + */ public Violations detectViolations() { Violations violations = rootPackages.stream() //