public interface NativeMethodEntityExtensionHandler<T> extends ExtensionHandler
Extension handler used for contributions to native Object methods on entity like equals() clone() and hashCode(). It is possible that dynamically weaved in columns from embeddables need to contribute to those methods.
Managers that implement this handler should add themselves to the blEntityExtensionManagers
list:
<bean id="myEntityExtensionManagers" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="blSomeEntityExtensionManager" value-ref="blSomeEntityExtensionManager"/>
</map>
</property>
</bean>
<bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
<property name="collectionRef" value="myEntityExtensionManagers"/>
<property name="targetRef" value="blEntityExtensionManagers"/>
</bean>
These blEntityExtensionManagers
are added onto the BroadleafRequestContext
with
BroadleafRequestContext.getAdditionalProperties()
. Native methods can use that to pull it off
Example use case is in SiteImpl.clone()
as well as CategoryImpl#getAllChildCategoryXrefs()
Modifier and Type | Method and Description |
---|---|
void |
contributeClone(T from,
T to)
Contributes additional properties to a cloned instance.
|
void |
contributeEquals(T original,
T test,
ExtensionResultHolder<Boolean> result)
Contributes additional equals() checks.
|
void |
contributeHashCode(T entity,
int precomputedHashCode,
ExtensionResultHolder<Integer> result)
Contributes more properties to build an object's hashCode().
|
getPriority, isEnabled
void contributeClone(T from, T to)
from
- the original instance that is being clonedto
- the instance that from is being cloned tovoid contributeEquals(T original, T test, ExtensionResultHolder<Boolean> result)
original
- the instance being checked for equals (the 'this' side of equals)test
- the instance being compared to original for equalityresult
- where the result should be stored if this extension managervoid contributeHashCode(T entity, int precomputedHashCode, ExtensionResultHolder<Integer> result)
entity
- the entity whose hashCode is being computedprecomputedHashCode
- the hashCode precomputed from the existing properties on entityresult
- where the final hashCode() should be storedCopyright © 2022. All rights reserved.