org.modelmapper
Interface TypeMap<S,D>

Type Parameters:
S - source type
D - destination type

public interface TypeMap<S,D>

Encapsulates mapping configuration for a source and destination type pair.

Author:
Jonathan Halterman

Method Summary
 void addMappings(PropertyMap<S,D> propertyMap)
          Loads mappings from the propertyMap into the TypeMap.
 Condition<?,?> getCondition()
          Returns the Condition that must apply in order for mapping to take place, else null if no condition has been configured.
 Converter<S,D> getConverter()
          Returns the Converter configured for this TypeMap, else null if no Converter has been configured.
 Class<D> getDestinationType()
          Returns the destination type for the TypeMap.
 List<Mapping> getMappings()
          Returns a snapshot of the TypeMap's mappings.
 Provider<D> getProvider()
          Returns the Provider configured for this TypeMap, else null if no Provider has been configured.
 Class<S> getSourceType()
          Returns the source type for the TypeMap.
 List<PropertyInfo> getUnmappedProperties()
          Returns a snapshot list of destination properties that do not have mappings defined, else empty list if all destination properties are mapped.
 D map(S source)
          Maps source to an instance of type D.
 void map(S source, D destination)
          Maps source to destination.
 TypeMap<S,D> setCondition(Condition<?,?> condition)
          Sets the condition that must apply in order for mapping to take place.
 TypeMap<S,D> setConverter(Converter<S,D> converter)
          Sets the converter to be used for any conversion requests for the TypeMap's source to destination type.
 TypeMap<S,D> setProvider(Provider<D> provider)
          Sets the provider to be used for providing instances of destination type D during mapping.
 void validate()
          Validates that every top level destination property is mapped to one and only one source property, or that a Converter was set.
 

Method Detail

addMappings

void addMappings(PropertyMap<S,D> propertyMap)
Loads mappings from the propertyMap into the TypeMap. Mappings defined in the propertyMap will override any implicit mappings for the same properties.

Parameters:
propertyMap - from which mappings should be loaded
Throws:
IllegalArgumentException - if propertyMap is null
ConfigurationException - if a configuration error occurs while adding mappings for the propertyMap

getCondition

Condition<?,?> getCondition()
Returns the Condition that must apply in order for mapping to take place, else null if no condition has been configured.

See Also:
setCondition(Condition)

getConverter

Converter<S,D> getConverter()
Returns the Converter configured for this TypeMap, else null if no Converter has been configured.

See Also:
setConverter(Converter)

getDestinationType

Class<D> getDestinationType()
Returns the destination type for the TypeMap.


getMappings

List<Mapping> getMappings()
Returns a snapshot of the TypeMap's mappings.

This method is part of the ModelMapper SPI.


getProvider

Provider<D> getProvider()
Returns the Provider configured for this TypeMap, else null if no Provider has been configured.

See Also:
setProvider(Provider)

getSourceType

Class<S> getSourceType()
Returns the source type for the TypeMap.


getUnmappedProperties

List<PropertyInfo> getUnmappedProperties()
Returns a snapshot list of destination properties that do not have mappings defined, else empty list if all destination properties are mapped.

This method is part of the ModelMapper SPI.


map

D map(S source)
Maps source to an instance of type D.

Parameters:
source - object to map from
Returns:
fully mapped instance of type D
Throws:
IllegalArgumentException - if source is null
MappingException - if an error occurs while mapping

map

void map(S source,
         D destination)
Maps source to destination.

Parameters:
source - object to map from
destination - object to map to
Throws:
IllegalArgumentException - if source or destination are null
MappingException - if an error occurs while mapping

setCondition

TypeMap<S,D> setCondition(Condition<?,?> condition)
Sets the condition that must apply in order for mapping to take place.

Throws:
IllegalArgumentException - if condition is null

setConverter

TypeMap<S,D> setConverter(Converter<S,D> converter)
Sets the converter to be used for any conversion requests for the TypeMap's source to destination type.

Throws:
IllegalArgumentException - if converter is null

setProvider

TypeMap<S,D> setProvider(Provider<D> provider)
Sets the provider to be used for providing instances of destination type D during mapping.

Throws:
IllegalArgumentException - if provider is null

validate

void validate()
Validates that every top level destination property is mapped to one and only one source property, or that a Converter was set. If not, a ConfigurationException is thrown detailing any missing mappings.

Throws:
ValidationException - if any TypeMaps contain unmapped properties


Copyright © 2011. All Rights Reserved.