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 Summary
ConstructorDescriptionDefaultProjectionFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionClass<?>
createProjection
(Class<?> repositoryDomain) Class<?>
createProjection
(Class<?> repositoryDomain, String projectionName) Class<?>
getExistingProjectionType
(Class<?> repositoryDomain) protected Class<?>
getExistingProjectionType
(Class<?> repositoryDomain, boolean onlyIfDerived) Try to ascertain if a known projection type already exists for the specified domain class.static Class<?>
getProjectionType
(Class<?> repositoryDomain) Provides basic detection of projection type based on if the entity class implementsBusinessTypeAware
.protected boolean
shouldIgnore
(Field field) Whether or not the field from the domain class should be ignored and not copied into the projection.protected boolean
shouldProject
(Class<?> type) Whether or not the type for a field warrants a projection class.
-
Constructor Details
-
DefaultProjectionFactory
public DefaultProjectionFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
createProjection
- Specified by:
createProjection
in interfacecom.broadleafcommerce.common.extension.projection.ProjectionFactory
-
createProjection
- Specified by:
createProjection
in interfacecom.broadleafcommerce.common.extension.projection.ProjectionFactory
-
getExistingProjectionType
- Specified by:
getExistingProjectionType
in interfacecom.broadleafcommerce.common.extension.projection.ProjectionFactory
-
getProjectionType
Provides basic detection of projection type based on if the entity class implementsBusinessTypeAware
.- 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 classonlyIfDerived
- 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
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
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
-