Package io.beanmapper.core.converter
Class AbstractBeanConverter<S,T>
java.lang.Object
io.beanmapper.core.converter.AbstractBeanConverter<S,T>
- All Implemented Interfaces:
BeanConverter
- Direct Known Subclasses:
AnyToEnumConverter
,SimpleBeanConverter
Template implementation of a single type converter.
- Since:
- Jun 18, 2015
- Author:
- Jeroen van Schagen
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Construct a new bean converter, dynamically resolving the source and target class.protected
AbstractBeanConverter
(Class<?> sourceClass, Class<?> targetClass) Construct a new bean converter, manually declaring the source and target class. -
Method Summary
Modifier and TypeMethodDescriptionfinal <U,
R> R convert
(BeanMapper beanMapper, U source, Class<R> targetClass, BeanPropertyMatch beanPropertyMatch) Converts the source instance into the desired target type.protected abstract T
Convert a source instance to the target type.protected boolean
isMatchingSource
(Class<?> sourceClass) protected boolean
isMatchingTarget
(Class<?> targetClass) final boolean
Determines whether the conversion of our source type to a target type is supported by this converter.
-
Field Details
-
beanMapper
-
-
Constructor Details
-
AbstractBeanConverter
protected AbstractBeanConverter()Construct a new bean converter, dynamically resolving the source and target class. -
AbstractBeanConverter
Construct a new bean converter, manually declaring the source and target class.- Parameters:
sourceClass
- the source classtargetClass
- the target class
-
-
Method Details
-
convert
public final <U,R> R convert(BeanMapper beanMapper, U source, Class<R> targetClass, BeanPropertyMatch beanPropertyMatch) Converts the source instance into the desired target type.- Specified by:
convert
in interfaceBeanConverter
- Parameters:
beanMapper
- the instance of BeanMapper to use for further mappingssource
- the source instancetargetClass
- the desired target typebeanPropertyMatch
- information on the field pair (source / target)- Returns:
- the converted source instance
-
doConvert
Convert a source instance to the target type.- Parameters:
source
- the source instancetargetClass
- the class type to convert to- Returns:
- the converted source instance
-
match
Determines whether the conversion of our source type to a target type is supported by this converter.- Specified by:
match
in interfaceBeanConverter
- Parameters:
sourceClass
- the source classtargetClass
- the target class- Returns:
true
if the conversion is supported, elsefalse
-
isMatchingSource
-
isMatchingTarget
-