T
- The declaring typeR
- The return typepublic abstract class AbstractQueryInterceptor<T,R> extends java.lang.Object implements DataInterceptor<T,R>
Query
.Modifier and Type | Field and Description |
---|---|
protected RepositoryOperations |
operations |
Modifier | Constructor and Description |
---|---|
protected |
AbstractQueryInterceptor(RepositoryOperations operations)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Number |
convertNumberArgumentIfNecessary(java.lang.Number number,
io.micronaut.core.type.Argument<?> argument)
Convert a number argument if necessary.
|
protected int |
count(java.lang.Iterable<?> iterable)
Count the items.
|
protected <RT> java.util.Optional<java.lang.Iterable<RT>> |
findEntitiesParameter(io.micronaut.aop.MethodInvocationContext<?,?> context,
java.lang.Class<RT> type)
Fid an entities parameter value in role.
|
protected <RT> java.util.Optional<RT> |
findEntityParameter(io.micronaut.aop.MethodInvocationContext<?,?> context,
java.lang.Class<RT> type)
Find an entity parameter value in role.
|
protected <E> DeleteBatchOperation<E> |
getDeleteBatchOperation(io.micronaut.aop.MethodInvocationContext<T,?> context,
java.lang.Class<E> rootEntity,
java.lang.Iterable<E> iterable)
Get the delete batch operation for the given context.
|
protected <E> DeleteBatchOperation<E> |
getDeleteBatchOperation(io.micronaut.aop.MethodInvocationContext<T,?> context,
java.lang.Iterable<E> iterable)
Get the delete batch operation for the given context.
|
protected <E> DeleteOperation<E> |
getDeleteOperation(io.micronaut.aop.MethodInvocationContext<T,?> context,
E entity)
Get the delete operation for the given context.
|
protected <RT> java.lang.Iterable<RT> |
getEntitiesParameter(io.micronaut.aop.MethodInvocationContext<?,?> context,
java.lang.Class<RT> type)
Retrieve an entities parameter value in role.
|
protected <RT> RT |
getEntityParameter(io.micronaut.aop.MethodInvocationContext<?,?> context,
java.lang.Class<RT> type)
Retrieve an entity parameter value in role.
|
protected <E> InsertBatchOperation<E> |
getInsertBatchOperation(io.micronaut.aop.MethodInvocationContext context,
java.lang.Class<E> rootEntity,
java.lang.Iterable<E> iterable)
Get the insert batch operation for the given context.
|
protected <E> InsertBatchOperation<E> |
getInsertBatchOperation(io.micronaut.aop.MethodInvocationContext context,
java.lang.Iterable<E> iterable)
Get the insert batch operation for the given context.
|
protected <E> InsertOperation<E> |
getInsertOperation(io.micronaut.aop.MethodInvocationContext context)
Get the batch operation for the given context.
|
protected <E> InsertOperation<E> |
getInsertOperation(io.micronaut.aop.MethodInvocationContext<T,?> context,
E entity)
Get the batch operation for the given context.
|
protected Pageable |
getPageable(io.micronaut.aop.MethodInvocationContext<?,?> context)
Resolves the
Pageable for the given context. |
protected <E> PagedQuery<E> |
getPagedQuery(io.micronaut.aop.MethodInvocationContext context)
Get the paged query for the given context.
|
protected java.lang.Object |
getRequiredEntity(io.micronaut.aop.MethodInvocationContext<T,?> context)
Looks up the entity to persist from the execution context, or throws an exception.
|
protected java.lang.Class<?> |
getRequiredRootEntity(io.micronaut.aop.MethodInvocationContext context)
Obtains the root entity or throws an exception if it not available.
|
protected <E> UpdateBatchOperation<E> |
getUpdateAllBatchOperation(io.micronaut.aop.MethodInvocationContext<T,?> context,
java.lang.Class<E> rootEntity,
java.lang.Iterable<E> iterable)
Get the update all batch operation for the given context.
|
protected <E> UpdateOperation<E> |
getUpdateOperation(io.micronaut.aop.MethodInvocationContext<T,?> context)
Get the batch operation for the given context.
|
protected <E> UpdateOperation<E> |
getUpdateOperation(io.micronaut.aop.MethodInvocationContext<T,?> context,
E entity)
Get the batch operation for the given context.
|
protected java.lang.Object |
instantiateEntity(java.lang.Class<?> rootEntity,
java.util.Map<java.lang.String,java.lang.Object> parameterValues)
Instantiate the given entity for the given parameter values.
|
protected boolean |
isNullable(io.micronaut.core.annotation.AnnotationMetadata metadata)
Return whether the metadata indicates the instance is nullable.
|
protected boolean |
isNumber(java.lang.Class<?> type)
Is the type a number.
|
protected PreparedQuery<?,java.lang.Number> |
prepareCountQuery(RepositoryMethodKey methodKey,
io.micronaut.aop.MethodInvocationContext<T,R> context)
Prepares a query for the given context.
|
protected PreparedQuery<?,?> |
prepareQuery(RepositoryMethodKey key,
io.micronaut.aop.MethodInvocationContext<T,R> context)
Prepares a query for the given context.
|
protected <RT> PreparedQuery<?,RT> |
prepareQuery(RepositoryMethodKey methodKey,
io.micronaut.aop.MethodInvocationContext<T,R> context,
java.lang.Class<RT> resultType)
Prepares a query for the given context.
|
protected void |
validateNullArguments(io.micronaut.aop.MethodInvocationContext<T,R> context)
Validates null arguments ensuring no argument is null unless declared so.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
intercept
protected final RepositoryOperations operations
protected AbstractQueryInterceptor(@NonNull RepositoryOperations operations)
operations
- The operationsprotected final PreparedQuery<?,?> prepareQuery(RepositoryMethodKey key, io.micronaut.aop.MethodInvocationContext<T,R> context)
key
- The method keycontext
- The contextprotected final <RT> PreparedQuery<?,RT> prepareQuery(RepositoryMethodKey methodKey, io.micronaut.aop.MethodInvocationContext<T,R> context, java.lang.Class<RT> resultType)
RT
- The result generic typemethodKey
- The method keycontext
- The contextresultType
- The result typeprotected final PreparedQuery<?,java.lang.Number> prepareCountQuery(RepositoryMethodKey methodKey, @NonNull io.micronaut.aop.MethodInvocationContext<T,R> context)
methodKey
- The method keycontext
- The context@NonNull protected java.lang.Class<?> getRequiredRootEntity(io.micronaut.aop.MethodInvocationContext context)
context
- The contextjava.lang.IllegalStateException
- If the root entity is unavailableprotected <RT> RT getEntityParameter(io.micronaut.aop.MethodInvocationContext<?,?> context, @NonNull java.lang.Class<RT> type)
RT
- The generic typecontext
- The contexttype
- The typeprotected <RT> java.lang.Iterable<RT> getEntitiesParameter(io.micronaut.aop.MethodInvocationContext<?,?> context, @NonNull java.lang.Class<RT> type)
RT
- The generic typecontext
- The contexttype
- The typeprotected <RT> java.util.Optional<RT> findEntityParameter(io.micronaut.aop.MethodInvocationContext<?,?> context, @NonNull java.lang.Class<RT> type)
RT
- The generic typecontext
- The contexttype
- The typeprotected <RT> java.util.Optional<java.lang.Iterable<RT>> findEntitiesParameter(io.micronaut.aop.MethodInvocationContext<?,?> context, @NonNull java.lang.Class<RT> type)
RT
- The generic typecontext
- The contexttype
- The type@NonNull protected Pageable getPageable(io.micronaut.aop.MethodInvocationContext<?,?> context)
Pageable
for the given context.context
- The pageableprotected boolean isNullable(@NonNull io.micronaut.core.annotation.AnnotationMetadata metadata)
metadata
- The metadata@NonNull protected java.lang.Object getRequiredEntity(io.micronaut.aop.MethodInvocationContext<T,?> context)
context
- The context@NonNull protected java.lang.Object instantiateEntity(@NonNull java.lang.Class<?> rootEntity, @NonNull java.util.Map<java.lang.String,java.lang.Object> parameterValues)
rootEntity
- The entityparameterValues
- The parameter valuesjava.lang.IllegalArgumentException
- if the entity cannot be instantiated due to an illegal argument@Nullable protected java.lang.Number convertNumberArgumentIfNecessary(java.lang.Number number, io.micronaut.core.type.Argument<?> argument)
number
- The numberargument
- The argument@NonNull protected <E> PagedQuery<E> getPagedQuery(@NonNull io.micronaut.aop.MethodInvocationContext context)
E
- The entity typecontext
- The context@NonNull protected <E> InsertBatchOperation<E> getInsertBatchOperation(@NonNull io.micronaut.aop.MethodInvocationContext context, @NonNull java.lang.Iterable<E> iterable)
E
- The entity typecontext
- The contextiterable
- The iterable@NonNull protected <E> InsertBatchOperation<E> getInsertBatchOperation(@NonNull io.micronaut.aop.MethodInvocationContext context, java.lang.Class<E> rootEntity, @NonNull java.lang.Iterable<E> iterable)
E
- The entity typecontext
- The contextrootEntity
- The root entityiterable
- The iterableprotected <E> InsertOperation<E> getInsertOperation(@NonNull io.micronaut.aop.MethodInvocationContext context)
E
- The entity typecontext
- The contextprotected <E> UpdateOperation<E> getUpdateOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context)
E
- The entity typecontext
- The contextprotected <E> UpdateOperation<E> getUpdateOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context, E entity)
E
- The entity typecontext
- The contextentity
- The entity instance@NonNull protected <E> UpdateBatchOperation<E> getUpdateAllBatchOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context, java.lang.Class<E> rootEntity, @NonNull java.lang.Iterable<E> iterable)
E
- The entity typerootEntity
- The root entitrycontext
- The contextiterable
- The iterableprotected <E> DeleteOperation<E> getDeleteOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context, @NonNull E entity)
E
- The entity typecontext
- The contextentity
- The entity@NonNull protected <E> DeleteBatchOperation<E> getDeleteBatchOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context, @NonNull java.lang.Iterable<E> iterable)
E
- The entity typecontext
- The contextiterable
- The iterable@NonNull protected <E> DeleteBatchOperation<E> getDeleteBatchOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context, java.lang.Class<E> rootEntity, @NonNull java.lang.Iterable<E> iterable)
E
- The entity typecontext
- The contextrootEntity
- The root entityiterable
- The iterableprotected <E> InsertOperation<E> getInsertOperation(@NonNull io.micronaut.aop.MethodInvocationContext<T,?> context, E entity)
E
- The entity typecontext
- The contextentity
- The entityprotected final void validateNullArguments(io.micronaut.aop.MethodInvocationContext<T,R> context)
context
- The contextprotected int count(java.lang.Iterable<?> iterable)
iterable
- the iterableprotected boolean isNumber(@Nullable java.lang.Class<?> type)
type
- The type