Class ContainerExtractorBinder
java.lang.Object
org.hibernate.search.mapper.pojo.extractor.impl.ContainerExtractorBinder
Binds
ContainerExtractorPaths to a given input type,
and allows to create extractors for a given BoundContainerExtractorPath.
The ContainerExtractorPath is independent from the input type.
This means in particular that the path needs to "bound" to an input type before it can be useful:
- First to check that the path applies correctly:
CollectionElementExtractorwon't work on aMap. - Second to determine the resulting value type:
[MapValueExtractor.class, CollectionElementExtractor.class]applied to aMap<String, Collection<Integer>>will result inIntegervalues. - Third, in the case of the default path, to determine the exact list of extractor classes.
For instance, for a
Collection<String>the default path will be resolved toCollectionElementExtractor. For aMap<String, Collection<Integer>>the default path will be resolved to[MapValueExtractor.class, CollectionElementExtractor.class].
BoundContainerExtractorPath,
which carries both a ContainerExtractorPath
(which is an explicit list of classes, and never ContainerExtractorPath.defaultExtractors(),
since the default path was resolved) and the resulting value type.
From this "bound path", the ContainerExtractorBinder is able to later create
a ContainerExtractor, which can be used at runtime to extract values from a container.
-
Constructor Summary
ConstructorsConstructorDescriptionContainerExtractorBinder(BeanResolver beanResolver, ContainerExtractorRegistry containerExtractorRegistry, TypePatternMatcherFactory typePatternMatcherFactory) -
Method Summary
Modifier and TypeMethodDescription<C> BoundContainerExtractorPath<C,?> bindPath(PojoTypeModel<C> sourceType, ContainerExtractorPath extractorPath) Bind a container extractor path to a given source type, i.e. resolve the possibly implicit extractor path (ContainerExtractorPath.defaultExtractors()) and validate that all extractors in the path can be applied, or fail.<C,V> ContainerExtractorHolder<C, V> create(BoundContainerExtractorPath<C, V> boundPath) Create a container value extractor from a bound path, or fail.<C> booleanisDefaultExtractorPath(PojoTypeModel<C> sourceType, ContainerExtractorPath extractorPath) <C> Optional<BoundContainerExtractorPath<C,?>> tryBindPath(PojoTypeModel<C> sourceType, ContainerExtractorPath extractorPath) Try to bind a container extractor path to a given source type, i.e. to resolve the possibly implicit extractor path (ContainerExtractorPath.defaultExtractors()) and to validate that all extractors in the path can be applied.
-
Constructor Details
-
ContainerExtractorBinder
public ContainerExtractorBinder(BeanResolver beanResolver, ContainerExtractorRegistry containerExtractorRegistry, TypePatternMatcherFactory typePatternMatcherFactory)
-
-
Method Details
-
tryBindPath
public <C> Optional<BoundContainerExtractorPath<C,?>> tryBindPath(PojoTypeModel<C> sourceType, ContainerExtractorPath extractorPath) Try to bind a container extractor path to a given source type, i.e. to resolve the possibly implicit extractor path (ContainerExtractorPath.defaultExtractors()) and to validate that all extractors in the path can be applied.- Type Parameters:
C- The source type.- Parameters:
sourceType- A model of the source type to apply extractors to.extractorPath- The list of extractors to apply.- Returns:
- The resolved extractor path, or an empty optional if one of the extractors in the path cannot be applied.
-
bindPath
public <C> BoundContainerExtractorPath<C,?> bindPath(PojoTypeModel<C> sourceType, ContainerExtractorPath extractorPath) Bind a container extractor path to a given source type, i.e. resolve the possibly implicit extractor path (ContainerExtractorPath.defaultExtractors()) and validate that all extractors in the path can be applied, or fail.- Type Parameters:
C- The source type.- Parameters:
sourceType- A model of the source type to apply extractors to.extractorPath- The list of extractors to apply.- Returns:
- The bound extractor path.
- Throws:
SearchException- if one of the extractors in the path cannot be applied.
-
create
Create a container value extractor from a bound path, or fail.- Type Parameters:
C- The source type.V- The extracted value type.- Parameters:
boundPath- The bound path to create the extractor from.- Returns:
- The extractor.
- Throws:
AssertionFailure- if the bound path was empty
-
isDefaultExtractorPath
public <C> boolean isDefaultExtractorPath(PojoTypeModel<C> sourceType, ContainerExtractorPath extractorPath)
-