T - target typepublic abstract class AbstractAssembleOperationHandler<T extends AbstractAssembleOperationHandler.Target> extends Object implements AssembleOperationHandler
This class serves as the top-level template class
and defines the key steps required by most AssembleOperationHandler:
Object processing phase:
collectToEntities(java.util.Collection<cn.crane4j.core.executor.AssembleExecution>): Expands the target objects to be operated on from the AssembleExecution
and wraps them as AbstractAssembleOperationHandler.Target objects, which will be used for subsequent processing;
introspectForEntities(java.util.Collection<T>): If the Container for the current operation is not specified,
directly use the target objects as the data source for field mapping;
Container for the current operation is specified, it enters the data source preparation phase:
getSourcesFromContainer(cn.crane4j.core.container.Container<?>, java.util.Collection<T>): Obtains the required data sources based on the objects to be processed;
getTheAssociatedSource(T, java.util.Map<java.lang.Object, java.lang.Object>): Retrieves the associated data source object
corresponding to the key value of the object to be processed from the data sources;
completeMapping(java.lang.Object, T) method is called to perform property mapping between them.
The implementation logic of this template class is based on
the encapsulation of AbstractAssembleOperationHandler.Target, which may introduce unnecessary performance overhead.
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
AbstractAssembleOperationHandler.Target
Target object to be processed.
|
| 构造器和说明 |
|---|
AbstractAssembleOperationHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract Collection<T> |
collectToEntities(Collection<AssembleExecution> executions)
Split the
AssembleExecution into pending objects and wrap it as AbstractAssembleOperationHandler.Target. |
protected abstract void |
completeMapping(Object source,
T target)
Complete attribute mapping between the target object and the data source object.
|
protected abstract Map<Object,Object> |
getSourcesFromContainer(Container<?> container,
Collection<T> targets)
Obtain the corresponding data source object from the data source container based on the entity's key value.
|
protected abstract Object |
getTheAssociatedSource(T target,
Map<Object,Object> sources)
Get the data source object associated with the target object.
|
protected void |
introspectForEntities(Collection<T> targets)
When the container is
EmptyContainer, introspect the object to be processed. |
void |
process(Container<?> container,
Collection<AssembleExecution> executions)
Perform assembly operation.
|
public void process(Container<?> container, Collection<AssembleExecution> executions)
process 在接口中 AssembleOperationHandlercontainer - containerexecutions - operations to be performedprotected abstract Collection<T> collectToEntities(Collection<AssembleExecution> executions)
AssembleExecution into pending objects and wrap it as AbstractAssembleOperationHandler.Target.executions - executionsAbstractAssembleOperationHandler.Targetprotected void introspectForEntities(Collection<T> targets)
EmptyContainer, introspect the object to be processed.targets - targetsprotected abstract Map<Object,Object> getSourcesFromContainer(Container<?> container, Collection<T> targets)
container - containertargets - targetsprotected abstract Object getTheAssociatedSource(T target, Map<Object,Object> sources)
target - targetsources - sourcesCopyright © 2023. All rights reserved.