ma.glasnost.orika
Interface MapperFactory

All Known Implementing Classes:
DefaultMapperFactory

public interface MapperFactory

MapperFactory is used to both configure, register, and generate the underlying Mapper and Converter instances which will be used to perform the the mapping functions.

Author:
S.M. El Aatifi

Method Summary
 void build()
          Deprecated. this method no longer needs to be called by clients; the MapperFactory instances should automatically be built upon the first call to getMapperFacade().
<A,B> ClassMapBuilder<A,B>
classMap(Class<A> aType, Class<B> bType)
          Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.
<A,B> ClassMapBuilder<A,B>
classMap(Class<A> aType, Type<B> bType)
          Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.
<A,B> ClassMapBuilder<A,B>
classMap(Type<A> aType, Class<B> bType)
          Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.
<A,B> ClassMapBuilder<A,B>
classMap(Type<A> aType, Type<B> bType)
          Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.
 boolean existsRegisteredMapper(Type<?> sourceType, Type<?> destinationType, boolean includeAutoGeneratedMappers)
          Tests for the existence of a registered mapper which corresponds to the supplied mapperKey
<A,B> ClassMap<A,B>
getClassMap(MapperKey mapperKey)
          Gets the ClassMap instance (if any) which has been associated with the types represented by the given MapperKey instance.
 ConverterFactory getConverterFactory()
          Get an instance of the ConverterFactory associated with this MapperFactory; it may be used to register Converter instances to be used during mapping.
 MapperFacade getMapperFacade()
           
<A,B> BoundMapperFacade<A,B>
getMapperFacade(Class<A> aType, Class<B> bType)
          Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.
<A,B> BoundMapperFacade<A,B>
getMapperFacade(Class<A> aType, Class<B> bType, boolean containsCycles)
          Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.
In the case that false is provided for the 'containsCycles' parameter, an optimized mapper instance will be provided.
<A,B> BoundMapperFacade<A,B>
getMapperFacade(Type<A> aType, Type<B> bType)
          Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.
<A,B> BoundMapperFacade<A,B>
getMapperFacade(Type<A> aType, Type<B> bType, boolean containsCycles)
          Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.
In the case that false is provided for the 'containsCycles' parameter, an optimized mapper instance will be provided.
 UnenhanceStrategy getUserUnenhanceStrategy()
          Returns the UnenhanceStrategy associated with this MapperFactory, provided when this MapperFactory was constructed.
<S,D> Type<? extends D>
lookupConcreteDestinationType(Type<S> sourceType, Type<D> destinationType, MappingContext context)
           
 Set<Type<? extends Object>> lookupMappedClasses(Type<?> type)
          Get the set of classes which have been mapped for the specified type.
<A,B> Mapper<A,B>
lookupMapper(MapperKey mapperKey)
          Get the Mapper (if any) which has been associated with the given MapperKey.
<T> ObjectFactory<T>
lookupObjectFactory(Type<T> targetType)
          Return the object factory (if any) which has been registered for the given type.
 Set<ClassMap<Object,Object>> lookupUsedClassMap(MapperKey mapperKey)
          Lookup the class map hierarchy used for the mapping defined by the specified MapperKey, if any exists
<A,B> void
registerClassMap(ClassMap<A,B> classMap)
          Registers the given ClassMap instance with the factory; it will be used to configure an appropriate mapping.
<A,B> void
registerClassMap(ClassMapBuilder<A,B> builder)
          Registers the ClassMap configured by the specified ClassMapBuilder; it will be used to configure an appropriate mapping.
 void registerConcreteType(Class<?> abstractType, Class<?> concreteType)
          Register a concrete type to use when a need arises to generate a new instance of a given abstract type (abstract class or interface)
 void registerConcreteType(Type<?> abstractType, Type<?> concreteType)
          Register a concrete type to use when a need arises to generate a new instance of a given abstract type (abstract class or interface)
 void registerDefaultFieldMapper(DefaultFieldMapper... fieldDefaults)
          Register one or more DefaultFieldMapper instances to be used by this MapperFactory; these instances will be used whenever automatically generating a Mapper for a given pair of types.
<A,B> void
registerMapper(Mapper<A,B> mapper)
          Registers the specified custom mapper with the factory; it will be used for mapping between it's configured types.
 void registerMappingHint(MappingHint... hints)
          Deprecated. 
<T> void
registerObjectFactory(ObjectFactory<T> objectFactory, Class<T> targetClass)
          Deprecated. use registerObjectFactory(ObjectFactory, Type) instead.
<T> void
registerObjectFactory(ObjectFactory<T> objectFactory, Type<T> targetType)
          Register the given ObjectFactory with the MapperFactory; it will be used when constructing new instances of the specified targetType.
 

Method Detail

lookupMapper

<A,B> Mapper<A,B> lookupMapper(MapperKey mapperKey)
Get the Mapper (if any) which has been associated with the given MapperKey. If one does not exist, and the Mapper supports automatic generation, an appropriate mapper will be generated.

Parameters:
mapperKey - the MapperKey for which to look up an associated Mapper
Returns:
the Mapper associated with mapperKey;

existsRegisteredMapper

boolean existsRegisteredMapper(Type<?> sourceType,
                               Type<?> destinationType,
                               boolean includeAutoGeneratedMappers)
Tests for the existence of a registered mapper which corresponds to the supplied mapperKey

Parameters:
sourceType - the source type
destinationType - the destination type
includeAutoGeneratedMappers - specifies whether an auto-generated mapper for the given source and destination type should be considered
Returns:
true if such a mapper is registered with this factory

registerMapper

<A,B> void registerMapper(Mapper<A,B> mapper)
Registers the specified custom mapper with the factory; it will be used for mapping between it's configured types.

Parameters:
mapper - the mapper to register

registerClassMap

<A,B> void registerClassMap(ClassMap<A,B> classMap)
Registers the given ClassMap instance with the factory; it will be used to configure an appropriate mapping.

Parameters:
classMap - the ClassMap instance to register

registerClassMap

<A,B> void registerClassMap(ClassMapBuilder<A,B> builder)
Registers the ClassMap configured by the specified ClassMapBuilder; it will be used to configure an appropriate mapping.

Parameters:
builder - the ClassMapBuilder to register

registerObjectFactory

@Deprecated
<T> void registerObjectFactory(ObjectFactory<T> objectFactory,
                                          Class<T> targetClass)
Deprecated. use registerObjectFactory(ObjectFactory, Type) instead.

Register the given ObjectFactory with the MapperFactory; it will be used when constructing new instances of the specified targetType.

Parameters:
objectFactory - the object factory to register
targetType - the type which is generated by the given object factory

registerObjectFactory

<T> void registerObjectFactory(ObjectFactory<T> objectFactory,
                               Type<T> targetType)
Register the given ObjectFactory with the MapperFactory; it will be used when constructing new instances of the specified targetType.

Parameters:
objectFactory - the object factory to register
targetType - the type which is generated by the given object factory

lookupObjectFactory

<T> ObjectFactory<T> lookupObjectFactory(Type<T> targetType)
Return the object factory (if any) which has been registered for the given type.

Parameters:
targetType - the type for which to lookup a registered ObjectFactory.
Returns:
the ObjectFactory registered for the given targetType; null if no ObjectFactory has been registered for the given type.

lookupConcreteDestinationType

<S,D> Type<? extends D> lookupConcreteDestinationType(Type<S> sourceType,
                                                      Type<D> destinationType,
                                                      MappingContext context)
Parameters:
sourceType -
destinationType -
allowAutoGeneratedMappers -
context -
Returns:

registerMappingHint

@Deprecated
void registerMappingHint(MappingHint... hints)
Deprecated. 


registerDefaultFieldMapper

void registerDefaultFieldMapper(DefaultFieldMapper... fieldDefaults)
Register one or more DefaultFieldMapper instances to be used by this MapperFactory; these instances will be used whenever automatically generating a Mapper for a given pair of types.

Parameters:
fieldDefaults - one or more DefaultFieldMapper instances to register

registerConcreteType

void registerConcreteType(Type<?> abstractType,
                          Type<?> concreteType)
Register a concrete type to use when a need arises to generate a new instance of a given abstract type (abstract class or interface)

Parameters:
abstractType - the type of the abstract class or interface
concreteType - the concrete type to instantiate

registerConcreteType

void registerConcreteType(Class<?> abstractType,
                          Class<?> concreteType)
Register a concrete type to use when a need arises to generate a new instance of a given abstract type (abstract class or interface)

Parameters:
abstractType - the abstract class or interface
concreteType - the concrete class to instantiate

lookupUsedClassMap

Set<ClassMap<Object,Object>> lookupUsedClassMap(MapperKey mapperKey)
Lookup the class map hierarchy used for the mapping defined by the specified MapperKey, if any exists

Parameters:
mapperKey - the mapper key defining the mapping to resolve
Returns:
the set of class mappings in the hierarchy of mappings used for the specified mapper key

getClassMap

<A,B> ClassMap<A,B> getClassMap(MapperKey mapperKey)
Gets the ClassMap instance (if any) which has been associated with the types represented by the given MapperKey instance.

Parameters:
mapperKey - the MapperKey which should be used to look up an associated ClassMap
Returns:
the ClassMap which has been associated with the given MapperKey; null if no instance has been associated with this MapperKey instance.

lookupMappedClasses

Set<Type<? extends Object>> lookupMappedClasses(Type<?> type)
Get the set of classes which have been mapped for the specified type.

Parameters:
type - the type for which to look up mapped types
Returns:
the set of types which have been mapped for the specified type.

getMapperFacade

MapperFacade getMapperFacade()
Returns:
a thread-safe MapperFacade instance as configured by this MapperFactory

getMapperFacade

<A,B> BoundMapperFacade<A,B> getMapperFacade(Type<A> aType,
                                             Type<B> bType)
Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.

Parameters:
aType - the 'A' type for the returned DedicatedMapperFacade
bType - the 'B' type for the returned DedicatedMapperFacade

getMapperFacade

<A,B> BoundMapperFacade<A,B> getMapperFacade(Class<A> aType,
                                             Class<B> bType)
Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.

Parameters:
aType - the 'A' type for the returned DedicatedMapperFacade
bType - the 'B' type for the returned DedicatedMapperFacade

getMapperFacade

<A,B> BoundMapperFacade<A,B> getMapperFacade(Type<A> aType,
                                             Type<B> bType,
                                             boolean containsCycles)
Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.
In the case that false is provided for the 'containsCycles' parameter, an optimized mapper instance will be provided.

Parameters:
aType - the 'A' type for the returned DedicatedMapperFacade
bType - the 'B' type for the returned DedicatedMapperFacade
containsCycles - true if the object graph for the source and destination types may contain cycles in it's graph; if 'false', an optimized DedicatedMapperFacade instance can be provided.
Returns:

getMapperFacade

<A,B> BoundMapperFacade<A,B> getMapperFacade(Class<A> aType,
                                             Class<B> bType,
                                             boolean containsCycles)
Returns a BoundMapperFacade for the specified source and destination types; this mapper is bidirectional by default, and provides signatures for mapping in place, or with instantiation, as needed.
In the case that false is provided for the 'containsCycles' parameter, an optimized mapper instance will be provided.

Parameters:
aType - the 'A' type for the returned DedicatedMapperFacade
bType - the 'B' type for the returned DedicatedMapperFacade
containsCycles - true if the object graph for the source and destination types may contain cycles in it's graph; if 'false', an optimized DedicatedMapperFacade instance can be provided.
Returns:

getConverterFactory

ConverterFactory getConverterFactory()
Get an instance of the ConverterFactory associated with this MapperFactory; it may be used to register Converter instances to be used during mapping.

Returns:
the ConverterFactory instance associated with this MapperFactory;

build

void build()
Deprecated. this method no longer needs to be called by clients; the MapperFactory instances should automatically be built upon the first call to getMapperFacade().

Builds this MapperFactory.


classMap

<A,B> ClassMapBuilder<A,B> classMap(Type<A> aType,
                                    Type<B> bType)
Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.

Parameters:
aType - the Type instance representing the "A" side of the mapping
bType - the Type instance representing the "B" side of the mapping
Returns:

classMap

<A,B> ClassMapBuilder<A,B> classMap(Class<A> aType,
                                    Type<B> bType)
Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.

Parameters:
aType - the Class instance representing the "A" side of the mapping
bType - the Type instance representing the "B" side of the mapping
Returns:

classMap

<A,B> ClassMapBuilder<A,B> classMap(Type<A> aType,
                                    Class<B> bType)
Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.

Parameters:
aType - the Type instance representing the "A" side of the mapping
bType - the Class instance representing the "B" side of the mapping
Returns:

classMap

<A,B> ClassMapBuilder<A,B> classMap(Class<A> aType,
                                    Class<B> bType)
Constructs a new ClassMapBuilder instance initialized with the provided types which can be used to configure/customize the mapping between the two types.

The returned ClassMapBuilder instance, after being fully configured, should finally be registered with the factory using the registerClassMap method.

Parameters:
aType - the Class instance representing the "A" side of the mapping
bType - the Class instance representing the "B" side of the mapping
Returns:

getUserUnenhanceStrategy

UnenhanceStrategy getUserUnenhanceStrategy()
Returns the UnenhanceStrategy associated with this MapperFactory, provided when this MapperFactory was constructed.

Returns:
the UnenhanceStrategy associated with this MapperFactory.


Copyright © 2013 Glasnost. All Rights Reserved.