Package com.github.dozermapper.core
Class DozerBeanMapper
- java.lang.Object
-
- com.github.dozermapper.core.DozerBeanMapper
-
- All Implemented Interfaces:
Mapper,MapperModelContext
public class DozerBeanMapper extends Object implements Mapper, MapperModelContext
Public Dozer Mapper implementation. This should be used/defined as a singleton within your application. This class performs several one-time initializations and loads the custom xml mappings, so you will not want to create many instances of it for performance reasons. Typically a system will only have one DozerBeanMapper instance per VM. If you are using an IOC framework (i.e Spring), define the Mapper as singleton="true". If you are not using an IOC framework, a DozerBeanMapperSingletonWrapper convenience class has been provided in the Dozer jar.It is technically possible to have multiple DozerBeanMapper instances initialized, but it will hinder internal performance optimizations such as caching.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<CustomConverter>getCustomConverters()Returns a list of registeredCustomConverterMap<String,CustomConverter>getCustomConvertersWithId()Returns a list of registeredCustomConverterwhich can be referenced in mapping by provided ID.CustomFieldMappergetCustomFieldMapper()Returns a list of registeredCustomFieldMapperList<? extends EventListener>getEventListeners()Returns a list of registeredEventListenerMapperModelContextgetMapperModelContext()ReturnsMapperModelContextwhich allows readonly access to the Mapper modelList<String>getMappingFiles()Returns list of provided mapping file URLsMappingMetadatagetMappingMetadata()TheMappingMetadatainterface can be used to query information about the current mapping definitions.protected MappergetMappingProcessor()<T> Tmap(Object source, Class<T> destinationClass)Constructs new instance of destinationClass and performs mapping between from source<T> Tmap(Object source, Class<T> destinationClass, String mapId)Constructs new instance of destinationClass and performs mapping between from sourcevoidmap(Object source, Object destination)Performs mapping between source and destination objectsvoidmap(Object source, Object destination, String mapId)Performs mapping between source and destination objects
-
-
-
Method Detail
-
map
public void map(Object source, Object destination, String mapId) throws MappingException
Performs mapping between source and destination objects- Specified by:
mapin interfaceMapper- Parameters:
source- object to convert fromdestination- object to convert tomapId- id in configuration for mapping- Throws:
MappingException- mapping failure
-
map
public <T> T map(Object source, Class<T> destinationClass, String mapId) throws MappingException
Constructs new instance of destinationClass and performs mapping between from source- Specified by:
mapin interfaceMapper- Type Parameters:
T- type to convert to- Parameters:
source- object to convert fromdestinationClass- type to convert tomapId- id in configuration for mapping- Returns:
- mapped object
- Throws:
MappingException- mapping failure
-
map
public <T> T map(Object source, Class<T> destinationClass) throws MappingException
Constructs new instance of destinationClass and performs mapping between from source- Specified by:
mapin interfaceMapper- Type Parameters:
T- type to convert to- Parameters:
source- object to convert fromdestinationClass- type to convert to- Returns:
- mapped object
- Throws:
MappingException- mapping failure
-
map
public void map(Object source, Object destination) throws MappingException
Performs mapping between source and destination objects- Specified by:
mapin interfaceMapper- Parameters:
source- object to convert fromdestination- object to convert to- Throws:
MappingException- mapping failure
-
getMappingProcessor
protected Mapper getMappingProcessor()
-
getMappingMetadata
public MappingMetadata getMappingMetadata()
TheMappingMetadatainterface can be used to query information about the current mapping definitions. It provides read only access to all important classes and field mapping properties. When first called, initializes all mappings if map() has not yet been called.- Specified by:
getMappingMetadatain interfaceMapper- Returns:
- An instance of
MappingMetadatawhich serves starting point for querying mapping information.
-
getMapperModelContext
public MapperModelContext getMapperModelContext()
ReturnsMapperModelContextwhich allows readonly access to the Mapper model- Specified by:
getMapperModelContextin interfaceMapper- Returns:
- an instance of
MapperModelContext
-
getMappingFiles
public List<String> getMappingFiles()
Returns list of provided mapping file URLs- Specified by:
getMappingFilesin interfaceMapperModelContext- Returns:
- unmodifiable list of mapping files
-
getCustomConverters
public List<CustomConverter> getCustomConverters()
Returns a list of registeredCustomConverter- Specified by:
getCustomConvertersin interfaceMapperModelContext- Returns:
- unmodifiable list of converters
-
getCustomConvertersWithId
public Map<String,CustomConverter> getCustomConvertersWithId()
Returns a list of registeredCustomConverterwhich can be referenced in mapping by provided ID.- Specified by:
getCustomConvertersWithIdin interfaceMapperModelContext- Returns:
- unmodifiable list of converters
-
getEventListeners
public List<? extends EventListener> getEventListeners()
Returns a list of registeredEventListener- Specified by:
getEventListenersin interfaceMapperModelContext- Returns:
- unmodifiable list of listeners
-
getCustomFieldMapper
public CustomFieldMapper getCustomFieldMapper()
Returns a list of registeredCustomFieldMapper- Specified by:
getCustomFieldMapperin interfaceMapperModelContext- Returns:
- a custom field mapper
-
-