|
|
|
@ -52,7 +52,7 @@ import org.springframework.util.ReflectionUtils; |
|
|
|
* that returns {@code false}. Filters are {@link Predicate#and(Predicate) combined} so that multiple filters can be |
|
|
|
* that returns {@code false}. Filters are {@link Predicate#and(Predicate) combined} so that multiple filters can be |
|
|
|
* taken into account. A type/field/method must pass all filters to be considered for further inspection. |
|
|
|
* taken into account. A type/field/method must pass all filters to be considered for further inspection. |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* The collector uses {@link AotServices} to discover implementations of {@link TypeCollectorPredicateProvider} so that |
|
|
|
* The collector uses {@link AotServices} to discover implementations of {@link TypeCollectorFilters} so that |
|
|
|
* components using {@link TypeCollector} can contribute their own filtering logic to exclude types, fields, and methods |
|
|
|
* components using {@link TypeCollector} can contribute their own filtering logic to exclude types, fields, and methods |
|
|
|
* from being inspected. |
|
|
|
* from being inspected. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -66,8 +66,8 @@ public class TypeCollector { |
|
|
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(TypeCollector.class); |
|
|
|
private static final Log logger = LogFactory.getLog(TypeCollector.class); |
|
|
|
|
|
|
|
|
|
|
|
private static final AotServices<TypeCollectorPredicateProvider> providers = AotServices.factories() |
|
|
|
private static final AotServices<TypeCollectorFilters> providers = AotServices.factories() |
|
|
|
.load(TypeCollectorPredicateProvider.class); |
|
|
|
.load(TypeCollectorFilters.class); |
|
|
|
|
|
|
|
|
|
|
|
private Predicate<Class<?>> typeFilter = Predicates.isTrue(); |
|
|
|
private Predicate<Class<?>> typeFilter = Predicates.isTrue(); |
|
|
|
|
|
|
|
|
|
|
|
@ -76,7 +76,7 @@ public class TypeCollector { |
|
|
|
private Predicate<Field> fieldFilter = Predicates.isTrue(); |
|
|
|
private Predicate<Field> fieldFilter = Predicates.isTrue(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new {@link TypeCollector} applying all {@link TypeCollectorPredicateProvider} discovered through |
|
|
|
* Create a new {@link TypeCollector} applying all {@link TypeCollectorFilters} discovered through |
|
|
|
* {@link AotServices}. |
|
|
|
* {@link AotServices}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public TypeCollector() { |
|
|
|
public TypeCollector() { |
|
|
|
@ -105,6 +105,7 @@ public class TypeCollector { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param filter filter predicate matching a {@link Class}. |
|
|
|
* @param filter filter predicate matching a {@link Class}. |
|
|
|
* @return {@code this} TypeCollector instance. |
|
|
|
* @return {@code this} TypeCollector instance. |
|
|
|
|
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Contract("_ -> this") |
|
|
|
@Contract("_ -> this") |
|
|
|
public TypeCollector filterMethods(Predicate<Method> filter) { |
|
|
|
public TypeCollector filterMethods(Predicate<Method> filter) { |
|
|
|
@ -117,6 +118,7 @@ public class TypeCollector { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param filter filter predicate matching a {@link Class}. |
|
|
|
* @param filter filter predicate matching a {@link Class}. |
|
|
|
* @return {@code this} TypeCollector instance. |
|
|
|
* @return {@code this} TypeCollector instance. |
|
|
|
|
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Contract("_ -> this") |
|
|
|
@Contract("_ -> this") |
|
|
|
public TypeCollector filterFields(Predicate<Field> filter) { |
|
|
|
public TypeCollector filterFields(Predicate<Field> filter) { |
|
|
|
@ -351,7 +353,7 @@ public class TypeCollector { |
|
|
|
* @author Mark Paluch |
|
|
|
* @author Mark Paluch |
|
|
|
* @since 4.0 |
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public interface TypeCollectorPredicateProvider { |
|
|
|
public interface TypeCollectorFilters { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return a predicate to filter types. |
|
|
|
* Return a predicate to filter types. |
|
|
|
@ -383,12 +385,12 @@ public class TypeCollector { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Default implementation of {@link TypeCollectorPredicateProvider} that excludes types from certain packages and |
|
|
|
* Default implementation of {@link TypeCollectorFilters} that excludes types from certain packages and |
|
|
|
* filters out unwanted fields and methods. |
|
|
|
* filters out unwanted fields and methods. |
|
|
|
* |
|
|
|
* |
|
|
|
* @since 4.0 |
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static class DefaultTypeCollectorPredicateProvider implements TypeCollectorPredicateProvider { |
|
|
|
private static class DefaultTypeCollectorFilters implements TypeCollectorFilters { |
|
|
|
|
|
|
|
|
|
|
|
private static final Set<String> EXCLUDED_DOMAINS = Set.of("java", "sun.", "jdk.", "reactor.", "kotlinx.", |
|
|
|
private static final Set<String> EXCLUDED_DOMAINS = Set.of("java", "sun.", "jdk.", "reactor.", "kotlinx.", |
|
|
|
"kotlin.", "org.springframework.core.", "org.springframework.data.mapping.", |
|
|
|
"kotlin.", "org.springframework.core.", "org.springframework.data.mapping.", |
|
|
|
|