@@ -0,0 +1,2315 @@
+/*%0A * Copyright 2015-2017 the original author or authors.%0A *%0A * All rights reserved. This program and the accompanying materials are%0A * made available under the terms of the Eclipse Public License v2.0 which%0A * accompanies this distribution and is available at%0A *%0A * http://www.eclipse.org/legal/epl-v20.html%0A */%0A%0Apackage org.junit.platform.commons.util;%0A%0Aimport static org.apiguardian.api.API.Status.INTERNAL;%0A%0Aimport java.util.function.Predicate;%0A%0Aimport org.apiguardian.api.API;%0A%0A/**%0A * Class-related predicate holder used by reflection utilities.%0A *%0A * %3Ch3%3EDISCLAIMER%3C/h3%3E%0A *%0A * %3Cp%3EThese utilities are intended solely for usage within the JUnit framework%0A * itself. %3Cstrong%3EAny usage by external parties is not supported.%3C/strong%3E%0A * Use at your own risk!%0A *%0A * @since 1.1%0A */%0A@API(status = INTERNAL, since = %221.1%22)%0Apublic class ClassFilter implements Predicate%3CClass%3C?%3E%3E %7B%0A%0A%09/**%0A%09 * Create a %7B@link ClassFilter%7D instance that accepts all names but filters classes.%0A%09 */%0A%09public static ClassFilter of(Predicate%3CClass%3C?%3E%3E classPredicate) %7B%0A%09%09return of(name -%3E true, classPredicate);%0A%09%7D%0A%0A%09/**%0A%09 * Create a %7B@link ClassFilter%7D instance that filters by names and classes.%0A%09 */%0A%09public static ClassFilter of(Predicate%3CString%3E namePredicate, Predicate%3CClass%3C?%3E%3E classPredicate) %7B%0A%09%09Preconditions.notNull(namePredicate, %22name predicate must not be null%22);%0A%09%09Preconditions.notNull(classPredicate, %22class predicate must not be null%22);%0A%0A%09%09return new ClassFilter(namePredicate, classPredicate);%0A%09%7D%0A%0A%09private final Predicate%3CString%3E namePredicate;%0A%09private final Predicate%3CClass%3C?%3E%3E classPredicate;%0A%0A%09private ClassFilter(Predicate%3CString%3E namePredicate, Predicate%3CClass%3C?%3E%3E classPredicate) %7B%0A%09%09this.classPredicate = classPredicate;%0A%09%09this.namePredicate = namePredicate;%0A%09%7D%0A%0A%09/**%0A%09 * Test name using the stored name predicate.%0A%09 */%0A%09public boolean match(String name) %7B%0A%09%09return namePredicate.test(name);%0A%09%7D%0A%0A%09/**%0A%09 * Test class using the stored class predicate.%0A%09 */%0A%09public boolean match(Class%3C?%3E type) %7B%0A%09%09return classPredicate.test(type);%0A%09%7D%0A%0A%09/**%0A%09 * %3Cp%3EimplNote This implementation combines all tests stored in the predicates%0A%09 * of this instance. Any new predicate must be added to this test method as%0A%09 * well.%0A%09 */%0A%09@Override%0A%09public boolean test(Class%3C?%3E type) %7B%0A%09%09return match(type.getName()) && match(type);%0A%09%7D%0A%7D%0A

Introduce internal predicate wrapper named ClassFilter