Class DefaultProjectionFactory

java.lang.Object
com.broadleafcommerce.data.tracking.core.mapping.DefaultProjectionFactory
All Implemented Interfaces:
com.broadleafcommerce.common.extension.projection.ProjectionFactory

public class DefaultProjectionFactory extends Object implements com.broadleafcommerce.common.extension.projection.ProjectionFactory
Author:
Jeff Fischer
See Also:
  • ProjectionFactory
  • Constructor Details

    • DefaultProjectionFactory

      public DefaultProjectionFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • Method Details

    • createProjection

      public Class<?> createProjection(Class<?> repositoryDomain)
      Specified by:
      createProjection in interface com.broadleafcommerce.common.extension.projection.ProjectionFactory
    • createProjection

      public Class<?> createProjection(Class<?> repositoryDomain, String projectionName)
      Specified by:
      createProjection in interface com.broadleafcommerce.common.extension.projection.ProjectionFactory
    • getExistingProjectionType

      public Class<?> getExistingProjectionType(Class<?> repositoryDomain)
      Specified by:
      getExistingProjectionType in interface com.broadleafcommerce.common.extension.projection.ProjectionFactory
    • getProjectionType

      public static Class<?> getProjectionType(Class<?> repositoryDomain)
      Provides basic detection of projection type based on if the entity class implements BusinessTypeAware.
      Parameters:
      repositoryDomain - The entity class to check for explicit projection declaration
      Returns:
      If implementing BusinessTypeAware, return the discovered projection. Otherwise, null.
    • getExistingProjectionType

      @Nullable protected Class<?> getExistingProjectionType(Class<?> repositoryDomain, boolean onlyIfDerived)
      Try to ascertain if a known projection type already exists for the specified domain class. This could be a projection type noted on a superclass. Will return null if no projection type was able to be ascertained for the domain class, or any of its ancestors.
      Parameters:
      repositoryDomain - The domain class to inspect for determination of a referenced projection class
      onlyIfDerived - Only attempt to determine the project type if it is explicitly declared in the repositoryDomain class (not a super class). Otherwise, return null.
      Returns:
      The identified projection class, or null if not found
    • shouldProject

      protected boolean shouldProject(Class<?> type)
      Whether or not the type for a field warrants a projection class. Primitive types, and standard types handled by Jackson can simply be copied to the containing projection class as field members without any special handling.
      Parameters:
      type - The field type in the domain class
      Returns:
      Whether or not the field type warrants a projection of its own
    • shouldIgnore

      protected boolean shouldIgnore(Field field)
      Whether or not the field from the domain class should be ignored and not copied into the projection.
      Parameters:
      field - The field to assess for inclusion
      Returns:
      Whether or not the field should be ignored