Class ConditionalFieldAnnotationsClassTransformer

java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
org.broadleafcommerce.common.extensibility.jpa.copy.ConditionalFieldAnnotationsClassTransformer
All Implemented Interfaces:
jakarta.persistence.spi.ClassTransformer, BroadleafClassTransformer, org.springframework.beans.factory.InitializingBean

public class ConditionalFieldAnnotationsClassTransformer extends AbstractClassTransformer implements BroadleafClassTransformer
The purpose of this class is to allow the conditional addition or removal of annotations to a target entity based on template class.

This does not add new fields or methods, nor does it remove fields or methods. Rather, this class copies annotations from a template class' field(s) to a target class' fields. It removes annotations from the target that are not on the template.

As a result, this class takes the annotations from fields of a template class and adds them to fields in a target class. If the template contains fields that are not on the target, then unexpected behavior such as NullPointerExceptions may occur.

Author:
Kelly Tisdell
  • Field Details

  • Constructor Details

    • ConditionalFieldAnnotationsClassTransformer

      public ConditionalFieldAnnotationsClassTransformer(String moduleName)
  • Method Details

    • transform

      public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws jakarta.persistence.spi.TransformerException
      Will return null if the Spring property value defined in #propertyName resolves to false, or if an exception occurs while trying to determine the value for the property.
      Specified by:
      transform in interface jakarta.persistence.spi.ClassTransformer
      Parameters:
      loader -
      className -
      classBeingRedefined -
      protectionDomain -
      classfileBuffer -
      Returns:
      Throws:
      IllegalClassFormatException
      jakarta.persistence.spi.TransformerException
    • compileJPAProperties

      public void compileJPAProperties(Properties props, Object key) throws Exception
      Specified by:
      compileJPAProperties in interface BroadleafClassTransformer
      Throws:
      Exception