public interface Configuration
| Modifier and Type | Interface and Description |
|---|---|
static class |
Configuration.AccessLevel
The level at and below which properties can be accessed.
|
| Modifier and Type | Method and Description |
|---|---|
<T> Configuration |
addValueReader(ValueReader<T> valueReader)
Registers the
valueReader to use when mapping from instances of types T. |
Configuration |
copy()
Returns a copy of the Configuration.
|
List<ConditionalConverter<?,?>> |
getConverters()
Gets the ordered list of internal conditional converters that are used to perform type
conversion.
|
NameTokenizer |
getDestinationNameTokenizer()
Returns the destination name tokenizer.
|
NameTransformer |
getDestinationNameTransformer()
Returns the destination name transformer.
|
NamingConvention |
getDestinationNamingConvention()
Returns the destination naming convention.
|
Configuration.AccessLevel |
getFieldAccessLevel()
Returns the field access level.
|
MatchingStrategy |
getMatchingStrategy()
Gets the matching strategy.
|
Configuration.AccessLevel |
getMethodAccessLevel()
Returns the method access level.
|
Condition<?,?> |
getPropertyCondition()
Returns the Condition that must apply for a property in order for mapping to take place, else
null if no condition has been configured. |
Provider<?> |
getProvider()
Returns the Provider used for provisioning destination object instances, else
null if
no Provider has been configured. |
NameTokenizer |
getSourceNameTokenizer()
Returns the source name tokenizer.
|
NameTransformer |
getSourceNameTransformer()
Returns the source name transformer.
|
NamingConvention |
getSourceNamingConvention()
Gets the source naming convention.
|
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.
|
boolean |
isAmbiguityIgnored()
Returns
true if ambiguous properties are ignored or false if they will result
in an exception. |
boolean |
isFieldMatchingEnabled()
Returns whether field matching is enabled.
|
boolean |
isFullTypeMatchingRequired()
|
boolean |
isImplicitMappingEnabled()
Returns whether implicit mapping should be enabled.
|
boolean |
isSkipNullEnabled()
Returns whether a property mapping will be skipped if the property value is
null. |
boolean |
isUseOSGiClassLoaderBridging()
Returns whether OSGi Class Loader Bridging is required.
|
Configuration |
setAmbiguityIgnored(boolean ignore)
Sets whether destination properties that match more than one source property should be ignored.
|
Configuration |
setDestinationNameTokenizer(NameTokenizer nameTokenizer)
Sets the tokenizer to be applied to destination property and class names during the matching
process.
|
Configuration |
setDestinationNameTransformer(NameTransformer nameTransformer)
Sets the name transformer used to transform destination property and class names during the
matching process.
|
Configuration |
setDestinationNamingConvention(NamingConvention namingConvention)
Sets the convention used to identify destination property names during the matching process.
|
Configuration |
setFieldAccessLevel(Configuration.AccessLevel accessLevel)
Indicates that fields should be eligible for matching at the given
accessLevel. |
Configuration |
setFieldMatchingEnabled(boolean enabled)
Sets whether field matching should be enabled.
|
Configuration |
setFullTypeMatchingRequired(boolean required)
Set whether
ConditionalConverters must define a full match in
order to be applied. |
Configuration |
setImplicitMappingEnabled(boolean enabled)
Sets whether implicit mapping should be enabled.
|
Configuration |
setMatchingStrategy(MatchingStrategy matchingStrategy)
Sets the strategy used to match source properties to destination properties.
|
Configuration |
setMethodAccessLevel(Configuration.AccessLevel accessLevel)
Indicates that methods should be eligible for matching at the given
accessLevel. |
Configuration |
setPropertyCondition(Condition<?,?> condition)
Sets the
condition that must apply for a property in order for mapping to take place. |
Configuration |
setProvider(Provider<?> provider)
Sets the
provider to use for providing destination object instances. |
Configuration |
setSkipNullEnabled(boolean enabled)
Sets whether a property should be skipped or not when the property value is
null. |
Configuration |
setSourceNameTokenizer(NameTokenizer nameTokenizer)
Sets the tokenizer to be applied to source property and class names during the matching
process.
|
Configuration |
setSourceNameTransformer(NameTransformer nameTransformer)
Sets the name transformer used to transform source property and class names during the matching
process.
|
Configuration |
setSourceNamingConvention(NamingConvention namingConvention)
Sets the convention used to identify source property names during the matching process.
|
Configuration |
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
|
<T> Configuration addValueReader(ValueReader<T> valueReader)
valueReader to use when mapping from instances of types T.
This method is part of the ModelMapper SPI.
T - source typevalueReader - to registerIllegalArgumentException - if valueReader is null or if type argument T
is not declared for the valueReaderConfiguration copy()
List<ConditionalConverter<?,?>> getConverters()
This method is part of the ModelMapper SPI.
NameTokenizer getDestinationNameTokenizer()
NameTransformer getDestinationNameTransformer()
NamingConvention getDestinationNamingConvention()
Configuration.AccessLevel getFieldAccessLevel()
setFieldAccessLevel(AccessLevel)MatchingStrategy getMatchingStrategy()
setMatchingStrategy(MatchingStrategy)Configuration.AccessLevel getMethodAccessLevel()
setMethodAccessLevel(AccessLevel)Condition<?,?> getPropertyCondition()
null if no condition has been configured.setPropertyCondition(Condition)Provider<?> getProvider()
null if
no Provider has been configured.setProvider(Provider)NameTokenizer getSourceNameTokenizer()
setSourceNameTokenizer(NameTokenizer)NameTransformer getSourceNameTransformer()
NamingConvention getSourceNamingConvention()
List<ValueReader<?>> getValueReaders()
The returned List throws an IllegalArgumentException when attempting to add or set a
ValueReader for which the type argument T has not been defined.
This method is part of the ModelMapper SPI.
boolean isAmbiguityIgnored()
true if ambiguous properties are ignored or false if they will result
in an exception.setAmbiguityIgnored(boolean)boolean isFieldMatchingEnabled()
setFieldMatchingEnabled(boolean)boolean isFullTypeMatchingRequired()
true if ConditionalConverters must define a full match in order to be applied. Otherwise conditional converters may also be applied for a
partial match.
Default is false.
setFullTypeMatchingRequired(boolean)boolean isImplicitMappingEnabled()
true (default), ModelMapper
will implicitly map source to destination properties based on configured conventions. When
false, only explicit mappings defined in property maps will be
used.setImplicitMappingEnabled(boolean)boolean isSkipNullEnabled()
null.
When true, ModelMapper will always not set null to destination property.setSkipNullEnabled(boolean)boolean isUseOSGiClassLoaderBridging()
setUseOSGiClassLoaderBridging(boolean)Configuration setAmbiguityIgnored(boolean ignore)
ignore - whether ambiguity is to be ignoredisAmbiguityIgnored()Configuration setDestinationNameTokenizer(NameTokenizer nameTokenizer)
IllegalArgumentException - if nameTokenizer is nullConfiguration setDestinationNameTransformer(NameTransformer nameTransformer)
IllegalArgumentException - if nameTransformer is nullConfiguration setDestinationNamingConvention(NamingConvention namingConvention)
IllegalArgumentException - if namingConvention is nullConfiguration setFieldAccessLevel(Configuration.AccessLevel accessLevel)
accessLevel.
Note: Field access is only used when field
matching is enabled.
IllegalArgumentException - if accessLevel is nullsetFieldMatchingEnabled(boolean)Configuration setFieldMatchingEnabled(boolean enabled)
false.enabled - whether field matching is enabledisFieldMatchingEnabled(),
setFieldAccessLevel(AccessLevel)Configuration setFullTypeMatchingRequired(boolean required)
ConditionalConverters must define a full match in
order to be applied. If false, conditional converters may also be applied for a
partial match.required - whether full type matching is required for conditional converters.isFullTypeMatchingRequired()Configuration setImplicitMappingEnabled(boolean enabled)
true (default), ModelMapper will
implicitly map source to destination properties based on configured conventions. When
false, only explicit mappings defined in property maps will be
used.enabled - whether implicit matching is enabledisImplicitMappingEnabled()Configuration setSkipNullEnabled(boolean enabled)
null.enabled - whether skip null is enabledisSkipNullEnabled()Configuration setUseOSGiClassLoaderBridging(boolean useOSGiClassLoaderBridging)
This 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.
useOSGiClassLoaderBridging - whether to use OSGi Class Loader Bridge. Default is falseisUseOSGiClassLoaderBridging()Configuration setMatchingStrategy(MatchingStrategy matchingStrategy)
IllegalArgumentException - if matchingStrategy is nullConfiguration setMethodAccessLevel(Configuration.AccessLevel accessLevel)
accessLevel.IllegalArgumentException - if accessLevel is nullConfiguration.AccessLevelConfiguration setPropertyCondition(Condition<?,?> condition)
condition that 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.IllegalArgumentException - if condition is nullConfiguration setProvider(Provider<?> provider)
provider to use for providing destination object instances.provider - to registerIllegalArgumentException - if provider is nullConfiguration setSourceNameTokenizer(NameTokenizer nameTokenizer)
IllegalArgumentException - if nameTokenizer is nullConfiguration setSourceNameTransformer(NameTransformer nameTransformer)
IllegalArgumentException - if nameTransformer is nullConfiguration setSourceNamingConvention(NamingConvention namingConvention)
IllegalArgumentException - if namingConvention is nullCopyright © 2011–2018. All rights reserved.