From eb44c8f5d03a34eabf0a70f4e83cc3184adc5661 Mon Sep 17 00:00:00 2001 From: mnhock Date: Tue, 18 Jun 2024 08:08:02 +0200 Subject: [PATCH] Clean up --- ...Predicates.java => GeneralPredicates.java} | 22 +++++++++---------- .../enofex/taikai/java/JavaConfigurer.java | 6 ++--- .../enofex/taikai/java/UtilityClasses.java | 2 +- .../taikai/spring/SpringPredicates.java | 2 +- .../enofex/taikai/test/JUnit5Configurer.java | 2 +- .../enofex/taikai/test/JUnit5Predicates.java | 3 +-- 6 files changed, 18 insertions(+), 19 deletions(-) rename src/main/java/com/enofex/taikai/{JavaPredicates.java => GeneralPredicates.java} (97%) diff --git a/src/main/java/com/enofex/taikai/JavaPredicates.java b/src/main/java/com/enofex/taikai/GeneralPredicates.java similarity index 97% rename from src/main/java/com/enofex/taikai/JavaPredicates.java rename to src/main/java/com/enofex/taikai/GeneralPredicates.java index 6cd4ce1..67cc3b7 100644 --- a/src/main/java/com/enofex/taikai/JavaPredicates.java +++ b/src/main/java/com/enofex/taikai/GeneralPredicates.java @@ -10,9 +10,9 @@ import com.tngtech.archunit.lang.ConditionEvents; import com.tngtech.archunit.lang.SimpleConditionEvent; -public final class JavaPredicates { +public final class GeneralPredicates { - private JavaPredicates() { + private GeneralPredicates() { } public static DescribedPredicate annotatedWith(String annotation, @@ -26,6 +26,15 @@ public boolean test(CanBeAnnotated canBeAnnotated) { }; } + public static DescribedPredicate areFinal() { + return new DescribedPredicate<>("are final") { + @Override + public boolean test(JavaClass javaClass) { + return javaClass.getModifiers().contains(JavaModifier.FINAL); + } + }; + } + public static ArchCondition notDeclareThrownExceptions() { return new ArchCondition<>("not declare thrown exceptions") { @Override @@ -54,15 +63,6 @@ public void check(JavaField field, ConditionEvents events) { }; } - public static DescribedPredicate areFinal() { - return new DescribedPredicate<>("are final") { - @Override - public boolean test(JavaClass javaClass) { - return javaClass.getModifiers().contains(JavaModifier.FINAL); - } - }; - } - public static ArchCondition beFinal() { return new ArchCondition<>("be final") { @Override diff --git a/src/main/java/com/enofex/taikai/java/JavaConfigurer.java b/src/main/java/com/enofex/taikai/java/JavaConfigurer.java index 8abd0a6..fd2961f 100644 --- a/src/main/java/com/enofex/taikai/java/JavaConfigurer.java +++ b/src/main/java/com/enofex/taikai/java/JavaConfigurer.java @@ -1,8 +1,8 @@ package com.enofex.taikai.java; -import static com.enofex.taikai.JavaPredicates.areFinal; -import static com.enofex.taikai.JavaPredicates.beFinal; -import static com.enofex.taikai.JavaPredicates.notBePublic; +import static com.enofex.taikai.GeneralPredicates.areFinal; +import static com.enofex.taikai.GeneralPredicates.beFinal; +import static com.enofex.taikai.GeneralPredicates.notBePublic; import static com.enofex.taikai.java.Deprecations.notUseDeprecatedAPIs; import static com.enofex.taikai.java.HashCodeAndEquals.implementHashCodeAndEquals; import static com.enofex.taikai.java.NoSystemOutOrErr.notUseSystemOutOrErr; diff --git a/src/main/java/com/enofex/taikai/java/UtilityClasses.java b/src/main/java/com/enofex/taikai/java/UtilityClasses.java index 8d2db67..7e82a98 100644 --- a/src/main/java/com/enofex/taikai/java/UtilityClasses.java +++ b/src/main/java/com/enofex/taikai/java/UtilityClasses.java @@ -19,7 +19,7 @@ static GivenClassesConjunction utilityClasses() { return classes().that(haveOnlyStaticMethods()); } - static DescribedPredicate haveOnlyStaticMethods() { + private static DescribedPredicate haveOnlyStaticMethods() { return new DescribedPredicate<>("have only static methods") { @Override public boolean test(JavaClass javaClass) { diff --git a/src/main/java/com/enofex/taikai/spring/SpringPredicates.java b/src/main/java/com/enofex/taikai/spring/SpringPredicates.java index 8bef12e..f021baf 100644 --- a/src/main/java/com/enofex/taikai/spring/SpringPredicates.java +++ b/src/main/java/com/enofex/taikai/spring/SpringPredicates.java @@ -1,6 +1,6 @@ package com.enofex.taikai.spring; -import static com.enofex.taikai.JavaPredicates.annotatedWith; +import static com.enofex.taikai.GeneralPredicates.annotatedWith; import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.properties.CanBeAnnotated; diff --git a/src/main/java/com/enofex/taikai/test/JUnit5Configurer.java b/src/main/java/com/enofex/taikai/test/JUnit5Configurer.java index 1562252..2a9d796 100644 --- a/src/main/java/com/enofex/taikai/test/JUnit5Configurer.java +++ b/src/main/java/com/enofex/taikai/test/JUnit5Configurer.java @@ -1,6 +1,6 @@ package com.enofex.taikai.test; -import static com.enofex.taikai.JavaPredicates.notDeclareThrownExceptions; +import static com.enofex.taikai.GeneralPredicates.notDeclareThrownExceptions; import static com.enofex.taikai.test.JUnit5Predicates.ANNOTATION_DISABLED; import static com.enofex.taikai.test.JUnit5Predicates.ANNOTATION_DISPLAY_NAME; import static com.enofex.taikai.test.JUnit5Predicates.ANNOTATION_PARAMETRIZED_TEST; diff --git a/src/main/java/com/enofex/taikai/test/JUnit5Predicates.java b/src/main/java/com/enofex/taikai/test/JUnit5Predicates.java index 173ae9e..77e2c35 100644 --- a/src/main/java/com/enofex/taikai/test/JUnit5Predicates.java +++ b/src/main/java/com/enofex/taikai/test/JUnit5Predicates.java @@ -1,6 +1,6 @@ package com.enofex.taikai.test; -import static com.enofex.taikai.JavaPredicates.annotatedWith; +import static com.enofex.taikai.GeneralPredicates.annotatedWith; import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.properties.CanBeAnnotated; @@ -12,7 +12,6 @@ final class JUnit5Predicates { static final String ANNOTATION_DISABLED = "org.junit.jupiter.api.Disabled"; static final String ANNOTATION_DISPLAY_NAME = "org.junit.jupiter.api.DisplayName"; - private JUnit5Predicates() { }