Package io.beanmapper.strategy
Class AbstractMapStrategy
java.lang.Object
io.beanmapper.strategy.AbstractMapStrategy
- All Implemented Interfaces:
MapStrategy
- Direct Known Subclasses:
MapCollectionStrategy
,MapToDynamicClassStrategy
,MapToInstanceStrategy
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractMapStrategy
(BeanMapper beanMapper, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionconvert
(Object value, Class<?> targetClass, BeanPropertyMatch beanPropertyMatch) Converts a value into the target class.<T,
S> BeanMatch getBeanMatch
(Class<S> sourceClazz, Class<T> targetClazz) getConstructorArguments
(S source, BeanMatch beanMatch) getConverterOptional
(Class<?> sourceClass, Class<?> targetClass) boolean
isMappable
(String packageName) Verifies whether the package is part of the beans which may be mapped by the bean mapper.boolean
isMappableClass
(Class<?> clazz) Verifies whether the class is part of the beans which may be mapped by the BeanMapper.<S,
T> T processProperties
(S source, T target, BeanMatch beanMatch) Try to match the source fields on the target fields from the given classes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.beanmapper.strategy.MapStrategy
map
-
Field Details
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
AbstractMapStrategy
-
-
Method Details
-
getConfiguration
-
getBeanMapper
-
getConstructorArguments
-
getBeanMatch
-
convert
Converts a value into the target class.- Parameters:
value
- the value to converttargetClass
- the target classbeanPropertyMatch
- contains the fields belonging to the source/target field match- Returns:
- the converted value
-
processProperties
Try to match the source fields on the target fields from the given classes. First get all fields on the right level with method getAllFields. Second match the fields and handle encapsulated classes. Finally copy the data from the source to the target.- Type Parameters:
S
- The source typeT
- The target type- Parameters:
source
- The source from which the values get copied.target
- The target to which the values get copied.beanMatch
- the matchup of source and target- Returns:
- A filled target object.
-
isMappableClass
Verifies whether the class is part of the beans which may be mapped by the BeanMapper. This logic is used when nested classes are encountered which need to be treated in a similar way as the main source/ target classes.- Parameters:
clazz
- the class to be verified against the allowed packages- Returns:
- true if the class may be mapped, false if it may not
-
isMappable
Verifies whether the package is part of the beans which may be mapped by the bean mapper. This logic is used when nested classes are encountered which need to be treated in a similar way as the main source/ target classes.- Parameters:
packageName
- the package- Returns:
- true if the class may be mapped, false if it may not
-
getConverterOptional
-