Created
October 28, 2025 13:29
-
-
Save ghusta/0bf6aeb516b6ac75b90b13fa53f1481d to your computer and use it in GitHub Desktop.
ArchUnit + JSpecify annotations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.tngtech.archunit.junit.AnalyzeClasses; | |
| import com.tngtech.archunit.junit.ArchTest; | |
| import com.tngtech.archunit.lang.ArchRule; | |
| import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; | |
| @AnalyzeClasses(packages = "my.package") | |
| public class PreferJSpecifyAnnotationsTest { | |
| @ArchTest | |
| static ArchRule classes_should_use_jspecify_annotations = | |
| noClasses() | |
| .should() | |
| .dependOnClassesThat() | |
| .haveFullyQualifiedName("org.springframework.lang.Nullable") | |
| .orShould() | |
| .dependOnClassesThat() | |
| .haveFullyQualifiedName("org.springframework.lang.NonNull") | |
| .because("Prefer JSpecify annotations"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment