public abstract class AbstractBeanOperationExecutor extends Object implements BeanOperationExecutor
This class serves as a template class and provides a basic skeleton implementation
for most of the BeanOperationExecutor,
particularly shielding the complexity of parsing DisassembleOperation operations.
Once the executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options) method is implemented in a subclass,
it can be used as a BeanOperationExecutor.
According to the instructions specified in BeanOperations,
the following steps are performed when executing operations through the BeanOperationExecutor.execute(java.util.Collection<?>, cn.crane4j.core.parser.BeanOperations, cn.crane4j.core.executor.BeanOperationExecutor.Options) method:
DisassembleOperation operations to be executed,
recursively extract and flatten the objects that need to be processed from
the target object (if it is a collection or an array, iterate over each element);
BeanOperations,
and wrap each group into an AssembleExecution object.
executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options) method implemented in the subclass to
actually perform the operations within each AssembleExecution.
This class only guarantees the sequential execution of DisassembleOperation operations,
while the sequential execution of AssembleOperation operations depends on
the implementation logic of executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options).
For performance reasons, when implementing the executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options) method,
it is recommended to minimize the number of accesses to the Container.
BeanOperationExecutor.Options| 限定符和类型 | 字段和说明 |
|---|---|
boolean |
enableExecuteNotActiveOperation
Whether to enable the execution of operations that are not active.
|
| 构造器和说明 |
|---|
AbstractBeanOperationExecutor() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
afterOperationsCompletion(MultiMap<BeanOperations,Object> targetWithOperations)
Do something after all operations completed.
|
protected void |
beforeAssembleOperation(MultiMap<BeanOperations,Object> targetWithOperations)
Do something before the assembly operation begin.
|
protected void |
beforeDisassembleOperation(Collection<?> targets,
BeanOperations operations,
BeanOperationExecutor.Options options)
Do something before the disassemble operations begin.
|
protected AssembleExecution |
createAssembleExecution(BeanOperations beanOperations,
AssembleOperation operation,
Collection<Object> targets,
BeanOperationExecutor.Options options)
Create a
AssembleExecution. |
protected @NonNull List<AssembleExecution> |
doCombineExecutions(BeanOperationExecutor.Options options,
Predicate<? super KeyTriggerOperation> filter,
BeanOperations beanOperations,
Collection<Object> targets)
|
protected static void |
doExecute(AssembleOperationHandler handler,
Container<?> container,
Collection<AssembleExecution> executions)
Try to execute the operation.
|
void |
execute(Collection<?> targets,
BeanOperations operations,
BeanOperationExecutor.Options options)
Complete operations on all objects in
targets according to the specified BeanOperations and Options. |
protected abstract void |
executeOperations(List<AssembleExecution> executions,
BeanOperationExecutor.Options options)
Complete the assembly operation.
|
protected <T> @NonNull Collection<T> |
filterTargetsForSupportedOperation(Collection<T> targets,
KeyTriggerOperation operation)
Filter the targets that do not support the operation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecute, executegetNamepublic boolean enableExecuteNotActiveOperation
public void execute(Collection<?> targets, BeanOperations operations, BeanOperationExecutor.Options options)
targets according to the specified BeanOperations and Options.execute 在接口中 BeanOperationExecutortargets - targetsoperations - operations to be performedoptions - options for executionbeforeDisassembleOperation(java.util.Collection<?>, cn.crane4j.core.parser.BeanOperations, cn.crane4j.core.executor.BeanOperationExecutor.Options),
beforeAssembleOperation(cn.crane4j.core.util.MultiMap<cn.crane4j.core.parser.BeanOperations, java.lang.Object>),
afterOperationsCompletion(cn.crane4j.core.util.MultiMap<cn.crane4j.core.parser.BeanOperations, java.lang.Object>)@NonNull protected @NonNull List<AssembleExecution> doCombineExecutions(BeanOperationExecutor.Options options, Predicate<? super KeyTriggerOperation> filter, BeanOperations beanOperations, Collection<Object> targets)
options - options for executionfilter - filterbeanOperations - bean operationstargets - targetsAssembleExecution objectsprotected AssembleExecution createAssembleExecution(BeanOperations beanOperations, AssembleOperation operation, Collection<Object> targets, BeanOperationExecutor.Options options)
AssembleExecution.beanOperations - bean operationsoperation - operationtargets - targetsoptions - options for executionAssembleExecutionprotected abstract void executeOperations(List<AssembleExecution> executions, BeanOperationExecutor.Options options) throws OperationExecuteException
Complete the assembly operation.
All operations of input parameters ensure their orderliness in the same class.
For example, if there are ordered operations a and b in A.class,
the order of a and b is still guaranteed when
the corresponding AssembleExecution is obtained.
executions - assembly operations to be completedoptions - options for executionOperationExecuteException - thrown when operation execution exceptionprotected void beforeAssembleOperation(MultiMap<BeanOperations,Object> targetWithOperations)
targetWithOperations - target with operationsprotected void beforeDisassembleOperation(Collection<?> targets, BeanOperations operations, BeanOperationExecutor.Options options)
targets - targetsoperations - operationsoptions - options for executionprotected void afterOperationsCompletion(MultiMap<BeanOperations,Object> targetWithOperations)
targetWithOperations - target with operations@NonNull protected <T> @NonNull Collection<T> filterTargetsForSupportedOperation(Collection<T> targets, KeyTriggerOperation operation)
targets - targetsoperation - operationprotected static void doExecute(AssembleOperationHandler handler, Container<?> container, Collection<AssembleExecution> executions)
Try to execute the operation.
If necessary, output the log when throwing an exception.
handler - handlerexecutions - executionscontainer - containerCopyright © 2024. All rights reserved.