Skip to content

Commit 1b32284

Browse files
committed
GH-44 - ApplicationModules.verify() now returns itself.
1 parent d3b87b8 commit 1b32284

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public static ApplicationModules of(Class<?> modulithType) {
121121
/**
122122
* Creates a new {@link ApplicationModules} relative to the given modulith type, a
123123
* {@link ApplicationModuleDetectionStrategy} and a {@link DescribedPredicate} which types and packages to ignore.
124-
* Will inspect the {@link Modulith} and {@link Modulithic} annotations on the class given for advanced
125-
* customizations of the module setup.
124+
* Will inspect the {@link Modulith} and {@link Modulithic} annotations on the class given for advanced customizations
125+
* of the module setup.
126126
*
127127
* @param modulithType must not be {@literal null}.
128128
* @param detection must not be {@literal null}.
@@ -280,19 +280,33 @@ public Optional<ApplicationModule> getModuleForPackage(String name) {
280280
.findFirst();
281281
}
282282

283-
public void verify() {
283+
/**
284+
* Execute all verifications to be applied, unless the verifcation has been executed before.
285+
*
286+
* @return will never be {@literal null}.
287+
*/
288+
public ApplicationModules verify() {
284289

285290
if (verified) {
286-
return;
291+
return this;
287292
}
288293

289294
Violations violations = detectViolations();
290295

291296
this.verified = true;
292297

293298
violations.throwIfPresent();
299+
300+
return this;
294301
}
295302

303+
/**
304+
* Executes all verifications to be applied and returns {@link Violations} if any occured. Will always execute the
305+
* verifications in contrast to {@link #verify()} which just runs once.
306+
*
307+
* @return will never be {@literal null}.
308+
* @see Violations#throwIfPresent()
309+
*/
296310
public Violations detectViolations() {
297311

298312
Violations violations = rootPackages.stream() //

0 commit comments

Comments
 (0)