From 4b26a08206a580a1fbdaf93ff9670135a1551de2 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 24 Jan 2025 19:21:48 -0800 Subject: [PATCH] Polish --- .../boot/build/architecture/ArchitectureRules.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java index bd34b1a59db..9b7b8838b7c 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java @@ -119,9 +119,9 @@ final class ArchitectureRules { .stream() .filter(notAnnotatedWithLazy) .filter((parameter) -> notOfASafeType.test(parameter.getRawType())) - .forEach((parameter) -> events.add(SimpleConditionEvent.violated(parameter, + .forEach((parameter) -> addViolation(events, parameter, parameter.getDescription() + " will cause eager initialization as it is " - + notAnnotatedWithLazy.getDescription() + " and is " + notOfASafeType.getDescription()))); + + notAnnotatedWithLazy.getDescription() + " and is " + notOfASafeType.getDescription())); } private static ArchRule allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveNoParameters() { @@ -193,8 +193,8 @@ final class ArchitectureRules { if (!properties.containsKey("type") && !properties.containsKey("name")) { conditionalAnnotation.get("value").ifPresent((value) -> { if (containsOnlySingleType((JavaType[]) value, item.getReturnType())) { - events.add(SimpleConditionEvent.violated(item, conditionalAnnotation.getDescription() - + " should not specify only a value that is the same as the method's return type")); + addViolation(events, item, conditionalAnnotation.getDescription() + + " should not specify only a value that is the same as the method's return type"); } }); } @@ -265,6 +265,10 @@ final class ArchitectureRules { }; } + private static void addViolation(ConditionEvents events, Object correspondingObject, String message) { + events.add(SimpleConditionEvent.violated(correspondingObject, message)); + } + private static String shouldUse(String string) { return string + " should be used instead"; }