Package io.beanmapper.config
Class OverrideConfiguration
java.lang.Object
io.beanmapper.config.OverrideConfiguration
- All Implemented Interfaces:
Configuration
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAfterClearFlusher
(AfterClearFlusher afterClearFlusher) After BeanMapper calls the clear() method on a collection, it will check for the presence of AfterClearFlusher instances.void
addBeanPairWithStrictSource
(Class source, Class target) Adds a new pair of classes of which the source is strict.void
addBeanPairWithStrictTarget
(Class source, Class target) Adds a new pair of classes of which the target is strict.void
addCollectionHandler
(CollectionHandler collectionHandler) Registers a collection handler to the configuration.void
addConverter
(BeanConverter converter) Add a converter class (must inherit from abstract BeanConverter class) to the beanMapper.<T,
V> void addCustomDefaultValueForClass
(Class<T> target, V value) Allows the user to set a default value for a given type.void
addLogicSecuredCheck
(LogicSecuredCheck logicSecuredCheck) Add a check instance that takes the source and target instances and on the basis of those two determines whether access must be providedvoid
addPackagePrefix
(Class<?> clazz) Adds a package on the basis of a class.void
addPackagePrefix
(String packagePrefix) Adds a package on the basis of a class.void
addProxySkipClass
(Class<?> clazz) Add classes to skip while unproxying to prevent failing of the BeanMapper while mapping proxy classes or classes containing synthetic fields (Like ENUM types).On the basis of the target, the targetClass will be determinedvoid
downsizeSource
(List<String> includeFields) Sets the field to downsize the source class.void
downsizeTarget
(List<String> includeFields) Sets the only fields that are allowed in the target class.Always use the CoreConfiguration beanmatch storeReturns the entire list of strict bean pairs.Always use the CoreConfiguration class storeThe class that represents the collection itself.Returns the collection clearer, which takes care of calling the clear method on a collection.getCollectionHandlerFor
(Class<?> clazz) Finds the correction handler for the class.Finds the collection handler for the collection class, null if not existsReturns the list of registered collection handlers.Returns the type of collection usage for the current collection mapping<T,
V> V getDefaultValueForClass
(Class<T> targetClass) Gets the default for the given target class.When include fields are passed, BeanMapper will assume that the generation (or reuse) of a dynamic class is required.When include fields are passed, BeanMapper will assume that the generation (or reuse) of a dynamic class is required.boolean
Property that determines if secured properties must be handled.Map<Class<? extends LogicSecuredCheck>,
LogicSecuredCheck> The active parent for the field that is currently being mapped.Class<?>
Gets the preferred collection class to be instantiated.The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured.Returns the collection of strictSourceSuffix, strictTargetSuffix and applyStrictMappingConvention properties.Returns the classname suffix that determines a source class is to be treated as strict with regards to mapping.Returns the classname suffix that determines a target class is to be treated as strict with regards to mapping.The target to map to.The class that represents the target class.boolean
Property that determines if null values for the source must be skipped or notboolean
boolean
Determines if strict mapping convention will be applied.boolean
Determines if the flush-chain must be called after a clear() operation on a collection has taken place.boolean
Determines if flushing has been enabled.boolean
Works on the combination of the global flush setting (flushEnabled) and the specific flush setting (flushAfterClear).void
setApplyStrictMappingConvention
(boolean applyStrictMappingConvention) Determines if strict mapping convention will be applied.void
setBeanInitializer
(BeanInitializer beanInitializer) void
setBeanUnproxy
(BeanUnproxy beanUnproxy) void
setCollectionClass
(Class collectionClass) Sets the collection class of the collection.void
setCollectionUsage
(BeanCollectionUsage collectionUsage) Sets the collection usage for the current collection mappingvoid
setConverterChoosable
(boolean converterChoosable) void
setEnforceSecuredProperties
(boolean enforceSecuredProperties) Property that determines if secured properties must be handled.void
setFlushAfterClear
(Trinary flushAfterClear) Determines whether the flush-chain must be called after a clear has taken place.void
setFlushEnabled
(boolean flushEnabled) Set whether flushing must be enabled.void
The active parent for the field that is currently being mapped.void
setPreferredCollectionClass
(Class<?> preferredCollectionClass) Sets the preferred collection class to be instantiated.void
setRoleSecuredCheck
(RoleSecuredCheck roleSecuredCheck) The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured.void
setStrictSourceSuffix
(String strictSourceSuffix) Sets the classname suffix that determines a source class is to be treated as strict with regards to mapping.void
setStrictTargetSuffix
(String strictTargetSuffix) Sets the classname suffix that determines a target class is to be treated as strict with regards to mapping.void
Sets the target.void
setTargetClass
(Class targetClass) Sets the target class.void
setUseNullValue
(boolean useNullValue) Property that determines if null values for the source must be skipped or notvoid
-
Constructor Details
-
OverrideConfiguration
-
-
Method Details
-
getDownsizeSource
Description copied from interface:Configuration
When include fields are passed, BeanMapper will assume that the generation (or reuse) of a dynamic class is required. For this, DynamicBeanMapper is used. Note that include fields is a marker field which impact the selection of the mapping strategy. Include fields never refer to the parent configuration.- Specified by:
getDownsizeSource
in interfaceConfiguration
- Returns:
- the fields to include in the source
-
getDownsizeTarget
Description copied from interface:Configuration
When include fields are passed, BeanMapper will assume that the generation (or reuse) of a dynamic class is required. For this, DynamicBeanMapper is used. Note that include fields is a marker field which impact the selection of the mapping strategy. Include fields never refer to the parent configuration.- Specified by:
getDownsizeTarget
in interfaceConfiguration
- Returns:
- the fields to include in the target
-
getCollectionClass
Description copied from interface:Configuration
The class that represents the collection itself. Used to instantiate a collection. Note that collection class is a marker field which impact the selection of the mapping strategy. Collection class never refers to the parent configuration.- Specified by:
getCollectionClass
in interfaceConfiguration
- Returns:
- class of the collection
-
setCollectionClass
Description copied from interface:Configuration
Sets the collection class of the collection. Used to instantiate the collection. If the collection class is set, it impacts the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.- Specified by:
setCollectionClass
in interfaceConfiguration
- Parameters:
collectionClass
- the class type of the collection
-
getCollectionHandlerForCollectionClass
Description copied from interface:Configuration
Finds the collection handler for the collection class, null if not exists- Specified by:
getCollectionHandlerForCollectionClass
in interfaceConfiguration
- Returns:
- the collection handler for the collection class, null if not exists
-
getCollectionHandlerFor
Description copied from interface:Configuration
Finds the correction handler for the class. Null, if not found.- Specified by:
getCollectionHandlerFor
in interfaceConfiguration
- Parameters:
clazz
- class to find the correct collection handler for- Returns:
- collection handler for the class, or null if not found
-
getTargetClass
Description copied from interface:Configuration
The class that represents the target class. Used to instantiate a target for the mapping. Note that target class is a marker field which impact the selection of the mapping strategy. Target class never refers to the parent configuration.- Specified by:
getTargetClass
in interfaceConfiguration
- Returns:
- class of the target
-
setTargetClass
Description copied from interface:Configuration
Sets the target class. Used to instantiate the target. If this class is set, it impact the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.- Specified by:
setTargetClass
in interfaceConfiguration
- Parameters:
targetClass
- the class type of the target
-
getTarget
Description copied from interface:Configuration
The target to map to. Note that collection class is a marker field which impact the selection of the mapping strategy. Target never refers to the parent configuration.- Specified by:
getTarget
in interfaceConfiguration
- Returns:
- class of the collection
-
setTarget
Description copied from interface:Configuration
Sets the target. If the target is set, it impact the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.- Specified by:
setTarget
in interfaceConfiguration
- Parameters:
target
- the target instance to map to
-
getParent
Description copied from interface:Configuration
The active parent for the field that is currently being mapped. This is always a parent on the target side of BeanMapper. @BeanParent makes us of this variable to assign to a field- Specified by:
getParent
in interfaceConfiguration
- Returns:
- the parent of the active field
-
setParent
Description copied from interface:Configuration
The active parent for the field that is currently being mapped. This is always a parent on the target side of BeanMapper. @BeanParent makes us of this variable to assign to a field- Specified by:
setParent
in interfaceConfiguration
- Parameters:
parent
- the parent of the active field
-
getBeanInitializer
- Specified by:
getBeanInitializer
in interfaceConfiguration
-
setBeanInitializer
- Specified by:
setBeanInitializer
in interfaceConfiguration
-
getBeanUnproxy
- Specified by:
getBeanUnproxy
in interfaceConfiguration
-
setBeanUnproxy
- Specified by:
setBeanUnproxy
in interfaceConfiguration
-
getBeanMatchStore
Description copied from interface:Configuration
Always use the CoreConfiguration beanmatch store- Specified by:
getBeanMatchStore
in interfaceConfiguration
- Returns:
- the one beanmatch store
-
getClassStore
Description copied from interface:Configuration
Always use the CoreConfiguration class store- Specified by:
getClassStore
in interfaceConfiguration
- Returns:
- the one class store
-
getPackagePrefixes
- Specified by:
getPackagePrefixes
in interfaceConfiguration
-
getBeanConverters
- Specified by:
getBeanConverters
in interfaceConfiguration
-
getLogicSecuredChecks
- Specified by:
getLogicSecuredChecks
in interfaceConfiguration
-
getCollectionHandlers
Description copied from interface:Configuration
Returns the list of registered collection handlers. The handlers are used to deal with the complexities of mapping between collections. Methods for copying, clearing and construction are supplied.- Specified by:
getCollectionHandlers
in interfaceConfiguration
- Returns:
- the list of registered collection handlers
-
getBeanPairs
Description copied from interface:Configuration
Returns the entire list of strict bean pairs. The properties on the strict side must have matching properties on the other, non-strict side.- Specified by:
getBeanPairs
in interfaceConfiguration
- Returns:
- the entire list of strict bean pairs.
-
isConverterChoosable
public boolean isConverterChoosable()- Specified by:
isConverterChoosable
in interfaceConfiguration
-
setConverterChoosable
public void setConverterChoosable(boolean converterChoosable) - Specified by:
setConverterChoosable
in interfaceConfiguration
-
withoutDefaultConverters
public void withoutDefaultConverters()- Specified by:
withoutDefaultConverters
in interfaceConfiguration
-
getStrictSourceSuffix
Description copied from interface:Configuration
Returns the classname suffix that determines a source class is to be treated as strict with regards to mapping. Default is "Form"- Specified by:
getStrictSourceSuffix
in interfaceConfiguration
- Returns:
- the source classname suffix for a class to be treated as strict
-
setStrictSourceSuffix
Description copied from interface:Configuration
Sets the classname suffix that determines a source class is to be treated as strict with regards to mapping. Default is "Form"- Specified by:
setStrictSourceSuffix
in interfaceConfiguration
- Parameters:
strictSourceSuffix
- the source classname suffix for a class to be treated as strict
-
getStrictTargetSuffix
Description copied from interface:Configuration
Returns the classname suffix that determines a target class is to be treated as strict with regards to mapping. Default is "Result"- Specified by:
getStrictTargetSuffix
in interfaceConfiguration
- Returns:
- the target classname suffix for a class to be treated as strict
-
setStrictTargetSuffix
Description copied from interface:Configuration
Sets the classname suffix that determines a target class is to be treated as strict with regards to mapping. Default is "Result"- Specified by:
setStrictTargetSuffix
in interfaceConfiguration
- Parameters:
strictTargetSuffix
- the target classname suffix for a class to be treated as strict
-
isApplyStrictMappingConvention
public boolean isApplyStrictMappingConvention()Description copied from interface:Configuration
Determines if strict mapping convention will be applied. This means that if a source class has the strict source suffix, or a target class has the strict target suffix, the classes will be treated as if they are strict. This implies that all of their properties will require matching properties on the other side. Default is true.- Specified by:
isApplyStrictMappingConvention
in interfaceConfiguration
- Returns:
- if true, the strict mapping convention will be applied
-
setApplyStrictMappingConvention
public void setApplyStrictMappingConvention(boolean applyStrictMappingConvention) Description copied from interface:Configuration
Determines if strict mapping convention will be applied. This means that if a source class has the strict source suffix, or a target class has the strict target suffix, the classes will be treated as if they are strict. This implies that all of their properties will require matching properties on the other side. Default is true.- Specified by:
setApplyStrictMappingConvention
in interfaceConfiguration
- Parameters:
applyStrictMappingConvention
- whether the strict mapping convention must be applied
-
getStrictMappingProperties
Description copied from interface:Configuration
Returns the collection of strictSourceSuffix, strictTargetSuffix and applyStrictMappingConvention properties.- Specified by:
getStrictMappingProperties
in interfaceConfiguration
- Returns:
- all properties required for dealing with the strict mapping convention
-
getPreferredCollectionClass
Description copied from interface:Configuration
Gets the preferred collection class to be instantiated. If it has this choice, it will use this class over the one provided by the collection handler.- Specified by:
getPreferredCollectionClass
in interfaceConfiguration
- Returns:
- the collection class to prefer for instantiation
-
setPreferredCollectionClass
Description copied from interface:Configuration
Sets the preferred collection class to be instantiated. If it has this choice, it will use this class over the one provided by the collection handler.- Specified by:
setPreferredCollectionClass
in interfaceConfiguration
- Parameters:
preferredCollectionClass
- the collection class to prefer for instantiation
-
getCollectionFlusher
Description copied from interface:Configuration
Returns the collection clearer, which takes care of calling the clear method on a collection. If required, it will also call the list of flushers registered to it.- Specified by:
getCollectionFlusher
in interfaceConfiguration
- Returns:
- the collection clearer
-
getCollectionUsage
Description copied from interface:Configuration
Returns the type of collection usage for the current collection mapping- Specified by:
getCollectionUsage
in interfaceConfiguration
- Returns:
- collection usage to apply
-
setCollectionUsage
Description copied from interface:Configuration
Sets the collection usage for the current collection mapping- Specified by:
setCollectionUsage
in interfaceConfiguration
- Parameters:
collectionUsage
- the collection usage to apply
-
isFlushAfterClear
Description copied from interface:Configuration
Determines if the flush-chain must be called after a clear() operation on a collection has taken place.- Specified by:
isFlushAfterClear
in interfaceConfiguration
- Returns:
- true if the flush-chain must be called after a clear
-
isFlushEnabled
public boolean isFlushEnabled()Description copied from interface:Configuration
Determines if flushing has been enabled. Flushing is the calling of flush() on a collection after it has been cleared. This force an ORM to run its delete queries. Default setting is false, because flushing is tied closely to having a transaction context. If, this is not the case, the flush will throw an exception.- Specified by:
isFlushEnabled
in interfaceConfiguration
- Returns:
- whether flushing has been enabled
-
setFlushEnabled
public void setFlushEnabled(boolean flushEnabled) Description copied from interface:Configuration
Set whether flushing must be enabled. Flushing is the calling of flush() on a collection after it has been cleared. This force an ORM to run its delete queries. Default setting is false, because flushing is tied closely to having a transaction context. If, this is not the case, the flush will throw an exception.- Specified by:
setFlushEnabled
in interfaceConfiguration
- Parameters:
flushEnabled
- whether flushing has been enabled
-
mustFlush
public boolean mustFlush()Description copied from interface:Configuration
Works on the combination of the global flush setting (flushEnabled) and the specific flush setting (flushAfterClear). If both are true, the flush will trigger.- Specified by:
mustFlush
in interfaceConfiguration
- Returns:
- true if a flush after clear must take place
-
getUseNullValue
public boolean getUseNullValue()Description copied from interface:Configuration
Property that determines if null values for the source must be skipped or not- Specified by:
getUseNullValue
in interfaceConfiguration
- Returns:
- determines if null values must be skipped or not
-
setUseNullValue
public void setUseNullValue(boolean useNullValue) Description copied from interface:Configuration
Property that determines if null values for the source must be skipped or not- Specified by:
setUseNullValue
in interfaceConfiguration
- Parameters:
useNullValue
- determines if null values must be skipped or not
-
getRoleSecuredCheck
Description copied from interface:Configuration
The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured. Returns the RoleSecuredCheck, if it has been configured.- Specified by:
getRoleSecuredCheck
in interfaceConfiguration
- Returns:
- the active RoleSecuredCheck, if set. Otherwise, null
-
setRoleSecuredCheck
Description copied from interface:Configuration
The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured.- Specified by:
setRoleSecuredCheck
in interfaceConfiguration
- Parameters:
roleSecuredCheck
- the new active RoleSecuredCheck
-
getEnforceSecuredProperties
public boolean getEnforceSecuredProperties()Description copied from interface:Configuration
Property that determines if secured properties must be handled. If this is set to true and the RoleSecuredCheck has not been set, an exception will be thrown.- Specified by:
getEnforceSecuredProperties
in interfaceConfiguration
- Returns:
- whether the handling of secured properties is enforced
-
setEnforceSecuredProperties
public void setEnforceSecuredProperties(boolean enforceSecuredProperties) Description copied from interface:Configuration
Property that determines if secured properties must be handled. If this is set to true and the RoleSecuredCheck has not been set, an exception will be thrown.- Specified by:
setEnforceSecuredProperties
in interfaceConfiguration
- Parameters:
enforceSecuredProperties
- whether the handling of secured properties is enforced
-
addConverter
Description copied from interface:Configuration
Add a converter class (must inherit from abstract BeanConverter class) to the beanMapper. On mapping, the beanMapper will check for a suitable converter and use its from and to methods to convert the value of the fields to the correct new data type.- Specified by:
addConverter
in interfaceConfiguration
- Parameters:
converter
- an instance of the class that contains the conversion method implementations and inherits from the abstract BeanConverter class.
-
addLogicSecuredCheck
Description copied from interface:Configuration
Add a check instance that takes the source and target instances and on the basis of those two determines whether access must be provided- Specified by:
addLogicSecuredCheck
in interfaceConfiguration
- Parameters:
logicSecuredCheck
- the check instance to register
-
addCollectionHandler
Description copied from interface:Configuration
Registers a collection handler to the configuration. The Collection handlers supply the underlying mechanism for dealing with mapping from and to collections. They supply methods for copying, clearing and construction.- Specified by:
addCollectionHandler
in interfaceConfiguration
- Parameters:
collectionHandler
- the collection handler to register
-
addBeanPairWithStrictSource
Description copied from interface:Configuration
Adds a new pair of classes of which the source is strict. The strict side must match for all public fields and getter properties.- Specified by:
addBeanPairWithStrictSource
in interfaceConfiguration
- Parameters:
source
- the source class that must match, also the strict side of the pairtarget
- the target class that must match
-
addBeanPairWithStrictTarget
Description copied from interface:Configuration
Adds a new pair of classes of which the target is strict. The strict side must match for all public fields and setter properties.- Specified by:
addBeanPairWithStrictTarget
in interfaceConfiguration
- Parameters:
source
- the source class that must matchtarget
- the target class that must match, also the strict side of the pair
-
addProxySkipClass
Description copied from interface:Configuration
Add classes to skip while unproxying to prevent failing of the BeanMapper while mapping proxy classes or classes containing synthetic fields (Like ENUM types).- Specified by:
addProxySkipClass
in interfaceConfiguration
- Parameters:
clazz
- the class that is added to the list of skipped classes
-
addPackagePrefix
Description copied from interface:Configuration
Adds a package on the basis of a class. All classes in that package and sub-packages are eligible for mapping. The root source and target do not need to be set as such, because the verification is only run against nested classes which should be mapped implicity as well- Specified by:
addPackagePrefix
in interfaceConfiguration
- Parameters:
clazz
- the class which sets the package prefix for all mappable classes
-
addPackagePrefix
Description copied from interface:Configuration
Adds a package on the basis of a class. All classes in that package and sub-packages are eligible for mapping. The root source and target do not need to be set as such, because the verification is only run against nested classes which should be mapped implicity as well- Specified by:
addPackagePrefix
in interfaceConfiguration
- Parameters:
packagePrefix
- the String which sets the package prefix for all mappable classes
-
addAfterClearFlusher
Description copied from interface:Configuration
After BeanMapper calls the clear() method on a collection, it will check for the presence of AfterClearFlusher instances. All instances found will be executed. The use case triggering this functionality is the fact that Hibernate's @OneToMany first executes insert SQL-statements, before the delete SQL statements. With constraints, this is an issue. By forcing the flush after a clear, Hibernate is forced to first execute its delete SQL-statements, before the inserts.- Specified by:
addAfterClearFlusher
in interfaceConfiguration
- Parameters:
afterClearFlusher
- the flusher to be added to the call stack after a clear call
-
isAddDefaultConverters
public boolean isAddDefaultConverters()- Specified by:
isAddDefaultConverters
in interfaceConfiguration
-
downsizeSource
Description copied from interface:Configuration
Sets the field to downsize the source class. THe limited source class is mapped over the given target class.- Specified by:
downsizeSource
in interfaceConfiguration
- Parameters:
includeFields
- The fields to be mapped to the target class.
-
downsizeTarget
Description copied from interface:Configuration
Sets the only fields that are allowed in the target class. If the include fields are set, it impacts the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.- Specified by:
downsizeTarget
in interfaceConfiguration
- Parameters:
includeFields
- The field that are allowed in the target class.
-
determineTargetClass
Description copied from interface:Configuration
On the basis of the target, the targetClass will be determined- Specified by:
determineTargetClass
in interfaceConfiguration
- Returns:
- the class of the target
-
setFlushAfterClear
Description copied from interface:Configuration
Determines whether the flush-chain must be called after a clear has taken place.- Specified by:
setFlushAfterClear
in interfaceConfiguration
- Parameters:
flushAfterClear
- true if the flush-chain must be called
-
addCustomDefaultValueForClass
Allows the user to set a default value for a given type.While the standard implementation of BeanMapper contains a utility-class
DefaultValues
, the map within is far from exhaustive. Furthermore, custom default values can serve as a useful compatibility feature for projects that would prefer different defaults.- Specified by:
addCustomDefaultValueForClass
in interfaceConfiguration
- Type Parameters:
T
- The type of the target.V
- The type of the value.- Parameters:
target
- The target class.value
- The default value for the given target class.
-
getDefaultValueForClass
Gets the default for the given target class.Any implementation of this method must first check the registered custom default values for a suitable value, if a container for custom defaults exists. Afterwards, the method may check a parent-configuration's custom defaults, or simply refer to the defaults in
DefaultValues
.- Specified by:
getDefaultValueForClass
in interfaceConfiguration
- Type Parameters:
T
- The type of the target-class.V
- The type of the associated value.- Parameters:
targetClass
- The target class- Returns:
- The value associated with the given target class, based off of the values set in the custom default values container, or the DefaultValues-class.
-