Class TypeCollector
java.lang.Object
org.springframework.data.util.TypeCollector
Collector to inspect domain types and discover the type graph that is relevant for Spring Data operations.
Type inspection walks through all class members (fields, methods, constructors) and introspects those for additional types that are part of the domain model.
Type collection can be customized by providing filters that stop introspection when encountering a Predicate
that returns false. Filters are combined so that multiple filters can be
taken into account. A type/field/method must pass all filters to be considered for further inspection.
The collector uses AotServices to discover implementations of TypeCollector.TypeCollectorFilters so that
components using TypeCollector can contribute their own filtering logic to exclude types, fields, and methods
from being inspected.
- Since:
- 3.0
- Author:
- Christoph Strobl, Sebastien Deleuze, John Blum, Mark Paluch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContainer for reachable types starting from a set of root types.static interfaceStrategy interface providing predicates to filter types, fields, and methods from being introspected and contributed to AOT processing. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newTypeCollectorapplying allTypeCollector.TypeCollectorFiltersdiscovered throughAotServices. -
Method Summary
Modifier and TypeMethodDescriptionfilterFields(Predicate<Field> filter) Add a filter to exclude fields from being introspected.filterMethods(Predicate<Method> filter) Add a filter to exclude methods from being introspected.filterTypes(Predicate<Class<?>> filter) Add a filter to exclude types from being introspected.static TypeCollector.ReachableTypesInspect the given type and resolve those reachable via fields, methods, generics, ...static TypeCollector.ReachableTypesinspect(Collection<Class<?>> types) Inspect the given type and resolve those reachable via fields, methods, generics, ...static TypeCollector.ReachableTypesinspect(Consumer<TypeCollector> collectorCustomizer, Class<?>... types) Inspect the given type and resolve those reachable via fields, methods, generics, ...static TypeCollector.ReachableTypesinspect(Consumer<TypeCollector> collectorCustomizer, Collection<Class<?>> types) Inspect the given type and resolve those reachable via fields, methods, generics, ...
-
Constructor Details
-
TypeCollector
public TypeCollector()Create a newTypeCollectorapplying allTypeCollector.TypeCollectorFiltersdiscovered throughAotServices.
-
-
Method Details
-
filterTypes
Add a filter to exclude types from being introspected.- Parameters:
filter- filter predicate matching aClass.- Returns:
thisTypeCollector instance.
-
filterMethods
Add a filter to exclude methods from being introspected.- Parameters:
filter- filter predicate matching aClass.- Returns:
thisTypeCollector instance.- Since:
- 4.0
-
filterFields
Add a filter to exclude fields from being introspected.- Parameters:
filter- filter predicate matching aClass.- Returns:
thisTypeCollector instance.- Since:
- 4.0
-
inspect
Inspect the given type and resolve those reachable via fields, methods, generics, ...- Parameters:
types- the types to inspect- Returns:
- a type model collector for the type
-
inspect
Inspect the given type and resolve those reachable via fields, methods, generics, ...- Parameters:
types- the types to inspect- Returns:
- a type model collector for the type
-
inspect
public static TypeCollector.ReachableTypes inspect(Consumer<TypeCollector> collectorCustomizer, Class<?>... types) Inspect the given type and resolve those reachable via fields, methods, generics, ...- Parameters:
collectorCustomizer- the customizer function to configure theTypeCollector.types- the types to inspect.- Returns:
- a type model collector for the type.
- Since:
- 4.0
-
inspect
public static TypeCollector.ReachableTypes inspect(Consumer<TypeCollector> collectorCustomizer, Collection<Class<?>> types) Inspect the given type and resolve those reachable via fields, methods, generics, ...- Parameters:
collectorCustomizer- the customizer function to configure theTypeCollector.types- the types to inspect.- Returns:
- a type model collector for the type.
- Since:
- 4.0
-