1515import java .util .function .Predicate ;
1616
1717import org .apiguardian .api .API ;
18- import org .junit .platform .commons .util .Preconditions ;
18+ import org .jspecify .annotations .Nullable ;
19+ import org .junit .platform .commons .PreconditionViolationException ;
20+ import org .junit .platform .commons .annotation .Contract ;
1921
2022/**
2123 * Resource filter used by reflection and classpath scanning support.
@@ -33,7 +35,7 @@ public class ResourceFilter {
3335 * @return an instance of {@code ResourceFilter}; never {@code null}
3436 */
3537 public static ResourceFilter of (Predicate <? super Resource > resourcePredicate ) {
36- return new ResourceFilter (Preconditions . notNull (resourcePredicate , "resourcePredicate must not be null " ));
38+ return new ResourceFilter (checkNotNull (resourcePredicate , "resourcePredicate" ));
3739 }
3840
3941 private final Predicate <? super Resource > predicate ;
@@ -50,7 +52,16 @@ private ResourceFilter(Predicate<? super Resource> predicate) {
5052 * {@code false}
5153 */
5254 public boolean match (Resource resource ) {
53- return predicate .test (Preconditions .notNull (resource , "resource must not be null" ));
55+ return predicate .test (checkNotNull (resource , "resource" ));
56+ }
57+
58+ // Cannot use Preconditions due to package cycle
59+ @ Contract ("null, _ -> fail; !null, _ -> param1" )
60+ private static <T > T checkNotNull (@ Nullable T input , String title ) {
61+ if (input == null ) {
62+ throw new PreconditionViolationException (title + " must not be null" );
63+ }
64+ return input ;
5465 }
5566
5667}
0 commit comments