Interface QueryPostProcessor<T extends org.springframework.data.repository.Repository,QUERY>
- Type Parameters:
T
-type
identifying theRepositories
to match on during registration.QUERY
-type
of the query to process.
- All Superinterfaces:
org.springframework.core.Ordered
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface QueryPostProcessor<T extends org.springframework.data.repository.Repository,QUERY>
extends org.springframework.core.Ordered
The
QueryPostProcessor
interface defines a contract for implementations to post process
a given query
and possibly return a new or modified version of the same query
.
QueryPostProcessors
are useful for handling and processing queries
derived from Repository
QueryMethods
, and give a developer the opportunity,
via the callback, to further process the generated query
.
QueryPostProcessors
can be used on both derived queries
and manual queries
. Manual queries
are defined as
queries
specified using SDG's @Query
annotation or by defining a named
query
in a module-specific Properties
files
(e.g. META-INF/gemfire-named-queries.properties).- Since:
- 2.1.0
- See Also:
-
FunctionalInterface
Ordered
Query
Repository
NamedQueries
QueryMethod
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
getOrder()
default QUERY
postProcess
(org.springframework.data.repository.query.QueryMethod queryMethod, QUERY query) postProcess
(org.springframework.data.repository.query.QueryMethod queryMethod, QUERY query, Object... arguments) default QueryPostProcessor<T,
QUERY> processAfter
(QueryPostProcessor<T, QUERY> queryPostProcessor) Builder method used to compose thisQueryPostProcessors
with the givenQueryPostProcessor
.default QueryPostProcessor<T,
QUERY> processBefore
(QueryPostProcessor<T, QUERY> queryPostProcessor) Builder method used to compose thisQueryPostProcessor
with the givenQueryPostProcessor
.
-
Field Details
-
EMPTY_ARGUMENTS
-
-
Method Details
-
getOrder
default int getOrder()Defines theorder
of thisQueryPostProcessor
relative to otherQueryPostProcessors
in a sort. Defaults to theOrdered.LOWEST_PRECEDENCE
.- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
- Returns:
- an
Integer
value specifying the order of thisQueryPostProcessor
relative to otherQueryPostProcessors
in a sort. - See Also:
-
Ordered.getOrder()
-
postProcess
default QUERY postProcess(@NonNull org.springframework.data.repository.query.QueryMethod queryMethod, QUERY query) Callback method invoked by the Spring Data (SD)Repository
framework to allow the user to process the givenquery
and (possibly) return a new or modified version of thequery
. This callback is invoked for queries generated from a SDRepository
QueryMethod
signature as well as queries specified and defined inNamedQueries
, or even using SDG's@Query
annotation.- Parameters:
query
-query
to process.- Returns:
- a new or modified version of the same
query
. - See Also:
-
QueryMethod
postProcess(QueryMethod, Object, Object...)
-
postProcess
QUERY postProcess(@NonNull org.springframework.data.repository.query.QueryMethod queryMethod, QUERY query, Object... arguments) Callback method invoked by the Spring Data (SD)Repository
framework to allow the user to process the givenquery
and (possibly) return a new or modified version of thequery
. This callback is invoked for queries generated from a SDRepository
QueryMethod
signature as well as queries specified and defined inNamedQueries
, or even using SDG's@Query
annotation.- Parameters:
query
-query
to process.arguments
- array ofObjects
containing the arguments to the query parameters.- Returns:
- a new or modified version of the same
query
. - See Also:
-
QueryMethod
postProcess(QueryMethod, Object)
-
processBefore
@NonNull default QueryPostProcessor<T,QUERY> processBefore(@Nullable QueryPostProcessor<T, QUERY> queryPostProcessor) Builder method used to compose thisQueryPostProcessor
with the givenQueryPostProcessor
. ThisQueryPostProcessor
will process the query before the givenQueryPostProcessor
in the processing chain.- Parameters:
queryPostProcessor
-QueryPostProcessor
to compose with thisQueryPostProcessor
.- Returns:
- a composed
QueryPostProcessor
consisting of thisQueryPostProcessor
followed by the givenQueryPostProcessor
. Returns thisQueryPostProcessor
if the givenQueryPostProcessor
is null. - See Also:
-
processAfter
@NonNull default QueryPostProcessor<T,QUERY> processAfter(@Nullable QueryPostProcessor<T, QUERY> queryPostProcessor) Builder method used to compose thisQueryPostProcessors
with the givenQueryPostProcessor
. ThisQueryPostProcessor
will process the query after the givenQueryPostProcessor
in the processing chain.- Parameters:
queryPostProcessor
-QueryPostProcessor
to compose with thisQueryPostProcessor
.- Returns:
- a composed
QueryPostProcessor
consisting of the givenQueryPostProcessor
followed by thisQueryPostProcessor
. Returns thisQueryPostProcessor
if the givenQueryPostProcessor
is null. - See Also:
-