Interface Configuration
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe level at and below which properties can be accessed. -
Method Summary
Modifier and TypeMethodDescription<T> ConfigurationaddValueReader(ValueReader<T> valueReader) Registers thevalueReaderto use when mapping from instances of typesT.<T> ConfigurationaddValueWriter(ValueWriter<T> valueWriter) Registers thevalueWriterto use when mapping property to instances of typesT.copy()Returns a copy of the Configuration.List<ConditionalConverter<?,?>> Gets the ordered list of internal conditional converters that are used to perform type conversion.Returns the destination name tokenizer.Returns the destination name transformer.Returns the destination naming convention.Returns the field access level.Gets the matching strategy.Returns the method access level.Condition<?,?> Returns the Condition that must apply for a property in order for mapping to take place, elsenullif no condition has been configured.Provider<?>Returns the Provider used for provisioning destination object instances, elsenullif no Provider has been configured.Returns the source name tokenizer.Returns the source name transformer.Gets the source naming convention.List<ValueReader<?>>Gets a thread-safe, mutable, ordered list of internal and user-defined ValueReaders that are used to read source object values during mapping.List<ValueWriter<?>>Gets a thread-safe, mutable, ordered list of internal and user-defined ValueWriters that are used to write destination object values during mapping.booleanReturnstrueif ambiguous properties are ignored orfalseif they will result in an exception.booleanReturns whether collections should be 'merged' when mapped.booleanReturns whether the deep copy feature is enabled.booleanReturns whether field matching is enabled.booleanbooleanReturns whether implicit mapping should be enabled.booleanReturns whether nested properties were preferred when ModelMapper were building the type map with implicit mapping.booleanReturns whether a property mapping will be skipped if the property value isnull.booleanReturns whether OSGi Class Loader Bridging is required.setAmbiguityIgnored(boolean ignore) Sets whether destination properties that match more than one source property should be ignored.setCollectionsMergeEnabled(boolean enabled) Sets whether the 'merging' of collections should be enabled.setDeepCopyEnabled(boolean enabled) Sets whether deep copy should be enabled.setDestinationNameTokenizer(NameTokenizer nameTokenizer) Sets the tokenizer to be applied to destination property and class names during the matching process.setDestinationNameTransformer(NameTransformer nameTransformer) Sets the name transformer used to transform destination property and class names during the matching process.setDestinationNamingConvention(NamingConvention namingConvention) Sets the convention used to identify destination property names during the matching process.setFieldAccessLevel(Configuration.AccessLevel accessLevel) Indicates that fields should be eligible for matching at the givenaccessLevel.setFieldMatchingEnabled(boolean enabled) Sets whether field matching should be enabled.setFullTypeMatchingRequired(boolean required) Set whetherConditionalConverters must define afullmatch in order to be applied.setImplicitMappingEnabled(boolean enabled) Sets whether implicit mapping should be enabled.setMatchingStrategy(MatchingStrategy matchingStrategy) Sets the strategy used to match source properties to destination properties.setMethodAccessLevel(Configuration.AccessLevel accessLevel) Indicates that methods should be eligible for matching at the givenaccessLevel.setPreferNestedProperties(boolean enabled) Sets whether nested properties were preferred when ModelMapper were building the type map with implicit mapping.setPropertyCondition(Condition<?, ?> condition) Sets theconditionthat must apply for a property in order for mapping to take place.setProvider(Provider<?> provider) Sets theproviderto use for providing destination object instances.setSkipNullEnabled(boolean enabled) Sets whether a property should be skipped or not when the property value isnull.setSourceNameTokenizer(NameTokenizer nameTokenizer) Sets the tokenizer to be applied to source property and class names during the matching process.setSourceNameTransformer(NameTransformer nameTransformer) Sets the name transformer used to transform source property and class names during the matching process.setSourceNamingConvention(NamingConvention namingConvention) Sets the convention used to identify source property names during the matching process.setUseOSGiClassLoaderBridging(boolean useOSGiClassLoaderBridging) Sets whether to use an OSGi Class Loader Bridge as described in the following article: https://www.infoq.com/articles/code-generation-with-osgi
-
Method Details
-
addValueReader
Registers thevalueReaderto use when mapping from instances of typesT.This method is part of the ModelMapper SPI.
- Type Parameters:
T- source type- Parameters:
valueReader- to register- Throws:
IllegalArgumentException- ifvalueReaderis null or if type argumentTis not declared for thevalueReader
-
addValueWriter
Registers thevalueWriterto use when mapping property to instances of typesT.This method is part of the ModelMapper SPI.
- Type Parameters:
T- source type- Parameters:
valueWriter- to register- Throws:
IllegalArgumentException- ifvalueWriteris null or if type argumentTis not declared for thevalueWriter
-
copy
Configuration copy()Returns a copy of the Configuration. -
getConverters
List<ConditionalConverter<?,?>> getConverters()Gets the ordered list of internal conditional converters that are used to perform type conversion. This list is mutable and may be modified to control which converters are used to perform type conversion along with the order in which converters are selected.This method is part of the ModelMapper SPI.
-
getDestinationNameTokenizer
NameTokenizer getDestinationNameTokenizer()Returns the destination name tokenizer. -
getDestinationNameTransformer
NameTransformer getDestinationNameTransformer()Returns the destination name transformer. -
getDestinationNamingConvention
NamingConvention getDestinationNamingConvention()Returns the destination naming convention. -
getFieldAccessLevel
Configuration.AccessLevel getFieldAccessLevel()Returns the field access level.- See Also:
-
getMatchingStrategy
MatchingStrategy getMatchingStrategy()Gets the matching strategy.- See Also:
-
getMethodAccessLevel
Configuration.AccessLevel getMethodAccessLevel()Returns the method access level.- See Also:
-
getPropertyCondition
Condition<?,?> getPropertyCondition()Returns the Condition that must apply for a property in order for mapping to take place, elsenullif no condition has been configured.- See Also:
-
getProvider
Provider<?> getProvider()Returns the Provider used for provisioning destination object instances, elsenullif no Provider has been configured.- See Also:
-
getSourceNameTokenizer
NameTokenizer getSourceNameTokenizer()Returns the source name tokenizer.- See Also:
-
getSourceNameTransformer
NameTransformer getSourceNameTransformer()Returns the source name transformer. -
getSourceNamingConvention
NamingConvention getSourceNamingConvention()Gets the source naming convention. -
getValueReaders
List<ValueReader<?>> getValueReaders()Gets a thread-safe, mutable, ordered list of internal and user-defined ValueReaders that are used to read source object values during mapping. This list is may be modified to control which ValueReaders are used to along with the order in which ValueReaders are selected for a source type.The returned List throws an IllegalArgumentException when attempting to add or set a ValueReader for which the type argument
Thas not been defined.This method is part of the ModelMapper SPI.
-
getValueWriters
List<ValueWriter<?>> getValueWriters()Gets a thread-safe, mutable, ordered list of internal and user-defined ValueWriters that are used to write destination object values during mapping. This list is may be modified to control which ValueWriters are used to along with the order in which ValueWriters are selected for a destination type.The returned List throws an IllegalArgumentException when attempting to add or set a ValueWriter for which the type argument
Thas not been defined.This method is part of the ModelMapper SPI.
-
isAmbiguityIgnored
boolean isAmbiguityIgnored()Returnstrueif ambiguous properties are ignored orfalseif they will result in an exception.- See Also:
-
isFieldMatchingEnabled
boolean isFieldMatchingEnabled()Returns whether field matching is enabled.- See Also:
-
isFullTypeMatchingRequired
boolean isFullTypeMatchingRequired()ReturnstrueifConditionalConverters must define afullmatch in order to be applied. Otherwise conditional converters may also be applied for apartialmatch.Default is
false.- See Also:
-
isImplicitMappingEnabled
boolean isImplicitMappingEnabled()Returns whether implicit mapping should be enabled. Whentrue(default), ModelMapper will implicitly map source to destination properties based on configured conventions. Whenfalse, only explicit mappings defined inproperty mapswill be used.- See Also:
-
isPreferNestedProperties
boolean isPreferNestedProperties()Returns whether nested properties were preferred when ModelMapper were building the type map with implicit mapping. Whentrue(default), ModelMapper will prefer looking for nested properties for a mapping definition. This option should be disabled when you are trying to map a model contains circular reference.modelMapper.createTypeMap(SourceTree.class, DestinationTree.class, modelMapper.getConfiguration().copy().setPreferNestedProperties(false));- See Also:
-
isSkipNullEnabled
boolean isSkipNullEnabled()Returns whether a property mapping will be skipped if the property value isnull. Whentrue, ModelMapper will always not setnullto destination property.- See Also:
-
isUseOSGiClassLoaderBridging
boolean isUseOSGiClassLoaderBridging()Returns whether OSGi Class Loader Bridging is required.- See Also:
-
isDeepCopyEnabled
boolean isDeepCopyEnabled()Returns whether the deep copy feature is enabled.- See Also:
-
setDeepCopyEnabled(boolean)AssignableConverter
-
isCollectionsMergeEnabled
boolean isCollectionsMergeEnabled()Returns whether collections should be 'merged' when mapped. Whentrue, mapping a source collection of sizemto a destination collection of sizenwithm < nresults in a collection with the firstmelements mapped from the source and elements fromm+1tonbeing preserved from the destination collection. Whenfalsethe elements of the destination collection are not preserved if they are not present in the source collection.- See Also:
-
setCollectionsMergeEnabled(boolean)MergingCollectionConverterNonMergingCollectionConverter
-
setAmbiguityIgnored
Sets whether destination properties that match more than one source property should be ignored. When true, ambiguous destination properties are skipped during the matching process. When false, a ConfigurationException is thrown when ambiguous properties are encountered.- Parameters:
ignore- whether ambiguity is to be ignored- See Also:
-
setDestinationNameTokenizer
Sets the tokenizer to be applied to destination property and class names during the matching process.- Throws:
IllegalArgumentException- ifnameTokenizeris null
-
setDestinationNameTransformer
Sets the name transformer used to transform destination property and class names during the matching process.- Throws:
IllegalArgumentException- ifnameTransformeris null
-
setDestinationNamingConvention
Sets the convention used to identify destination property names during the matching process.- Throws:
IllegalArgumentException- ifnamingConventionis null
-
setFieldAccessLevel
Indicates that fields should be eligible for matching at the givenaccessLevel.Note: Field access is only used when
field matchingis enabled.- Throws:
IllegalArgumentException- ifaccessLevelis null- See Also:
-
setFieldMatchingEnabled
Sets whether field matching should be enabled. When true, mapping may take place between accessible fields. Default isfalse.- Parameters:
enabled- whether field matching is enabled- See Also:
-
setFullTypeMatchingRequired
Set whetherConditionalConverters must define afullmatch in order to be applied. Iffalse, conditional converters may also be applied for apartialmatch.- Parameters:
required- whether full type matching is required for conditional converters.- See Also:
-
setImplicitMappingEnabled
Sets whether implicit mapping should be enabled. Whentrue(default), ModelMapper will implicitly map source to destination properties based on configured conventions. Whenfalse, only explicit mappings defined inproperty mapswill be used.- Parameters:
enabled- whether implicit matching is enabled- See Also:
-
setPreferNestedProperties
Sets whether nested properties were preferred when ModelMapper were building the type map with implicit mapping. Whentrue(default), ModelMapper will prefer looking for nested properties for a mapping definition. This option should be disabled when you are trying to map a model contains circular reference.modelMapper.createTypeMap(SourceTree.class, DestinationTree.class, modelMapper.getConfiguration().copy().setPreferNestedProperties(false));- Parameters:
enabled- whether prefer nested properties- See Also:
-
setSkipNullEnabled
Sets whether a property should be skipped or not when the property value isnull.- Parameters:
enabled- whether skip null is enabled- See Also:
-
setDeepCopyEnabled
Sets whether deep copy should be enabled. Whenfalse(default), ModelMapper will copy the reference to the destination object of a property if they have same type. Whentrue, ModelMapper will deep copy the property to destination object.- Parameters:
enabled- enabled whether deep copy is enabled- See Also:
-
isDeepCopyEnabled()AssignableConverter
-
setCollectionsMergeEnabled
Sets whether the 'merging' of collections should be enabled. Whentrue(default), ModelMapper will map the elements of the source collection to the destination collection and keep any elements of the destination collection when the source collection is smaller than the destination collection. Whenfalsethe destination collection only consists of the elements of the source collection after mapping.- Parameters:
enabled-- See Also:
-
isCollectionsMergeEnabled()MergingCollectionConverterNonMergingCollectionConverter
-
setUseOSGiClassLoaderBridging
Sets whether to use an OSGi Class Loader Bridge as described in the following article: https://www.infoq.com/articles/code-generation-with-osgiThis eliminates the need for forcing ModelMapper users to add custom OSGi imports to cglib's internals.
In addition to that, the Class Loader Bridge will attempt to solve the issue described in the following StackOverflow topic: https://stackoverflow.com/questions/47854086/cglib-creating-class-proxy-in-osgi-results-in-noclassdeffounderror
Ideally, this is expected to eliminate class loading issues in OSGi environments that were caused by missing custom imports.
Note: If Class Loader Bridging is selected, then the source and destination class types must not be package-private. That is because in Java, two classes are only consider equal to the JRE if they were loaded with the same class loader even if they otherwise represent an identical class. The same is true for Java packages. If a class is loaded with a different class loader, it cannot get private-package access to any classes (or class members) that belong to another class loader.
- Parameters:
useOSGiClassLoaderBridging- whether to use OSGi Class Loader Bridge. Default is false- See Also:
-
setMatchingStrategy
Sets the strategy used to match source properties to destination properties.- Throws:
IllegalArgumentException- ifmatchingStrategyis null
-
setMethodAccessLevel
Indicates that methods should be eligible for matching at the givenaccessLevel.- Throws:
IllegalArgumentException- ifaccessLevelis null- See Also:
-
setPropertyCondition
Sets theconditionthat must apply for a property in order for mapping to take place. This is overridden by any property conditions defined in a TypeMap or PropertyMap.- Throws:
IllegalArgumentException- ifconditionis null
-
setProvider
Sets theproviderto use for providing destination object instances.- Parameters:
provider- to register- Throws:
IllegalArgumentException- ifprovideris null
-
setSourceNameTokenizer
Sets the tokenizer to be applied to source property and class names during the matching process.- Throws:
IllegalArgumentException- ifnameTokenizeris null
-
setSourceNameTransformer
Sets the name transformer used to transform source property and class names during the matching process.- Throws:
IllegalArgumentException- ifnameTransformeris null
-
setSourceNamingConvention
Sets the convention used to identify source property names during the matching process.- Throws:
IllegalArgumentException- ifnamingConventionis null
-