|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectma.glasnost.orika.impl.DefaultMapperFactory
public class DefaultMapperFactory
The mapper factory is the heart of Orika, a small container where metadata are stored, it's used by other components, to look up for generated mappers, converters, object factories ... etc.
| Nested Class Summary | |
|---|---|
static class |
DefaultMapperFactory.Builder
Use this builder to generate instances of DefaultMapperFactory with the desired customizations. For example, an instance with no customizations could be generated with the following code: |
static class |
DefaultMapperFactory.MapperFactoryBuilder<F extends DefaultMapperFactory,B extends DefaultMapperFactory.MapperFactoryBuilder<F,B>>
MapperFactoryBuilder provides an extensible Builder definition usable for providing your own Builder class for subclasses of DefaultMapperFactory. See the defined DefaultMapperFactory.MapperFactoryBuilder below for example of how to subclass. |
| Constructor Summary | |
|---|---|
protected |
DefaultMapperFactory(DefaultMapperFactory.MapperFactoryBuilder<?,?> builder)
Constructs a new instance of DefaultMapperFactory |
| Method Summary | ||
|---|---|---|
protected void |
addClassMapBuilderFactory(ClassMapBuilderFactory factory)
Add factory to the factories chain |
|
void |
build()
Builds this MapperFactory. |
|
protected MapperFacade |
buildMapperFacade(MappingContextFactory contextFactory,
UnenhanceStrategy unenhanceStrategy)
Builds the MapperFacade for this factory. |
|
protected UnenhanceStrategy |
buildUnenhanceStrategy(UnenhanceStrategy unenhanceStrategy,
SuperTypeResolverStrategy superTypeStrategy)
Generates the UnenhanceStrategy to be used for this MapperFactory, applying the passed delegateStrategy if not null. This allows the MapperFactory a chance to fill in the unenhance strategy with references to other parts of the factory (registered mappers, converters, object factories) which may be important in the "unenhancing" process. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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 |
|
|
getClassMap(MapperKey mapperKey)
Gets the ClassMap instance (if any) which has been associated with the types represented by the given MapperKey instance. |
|
protected ClassMapBuilderFactory |
getClassMapBuilderFactory()
|
|
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()
|
|
|
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. |
|
|
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. |
|
|
getMapperFacade(Type<S> sourceType,
Type<D> destinationType)
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. |
|
|
getMapperFacade(Type<S> sourceType,
Type<D> destinationType,
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. |
|
protected
|
getRegisteredMapper(MapperKey mapperKey)
|
|
protected
|
getRegisteredMapper(Type<A> typeA,
Type<B> typeB,
boolean includeAutoGeneratedMappers)
|
|
UnenhanceStrategy |
getUserUnenhanceStrategy()
Returns the UnenhanceStrategy associated with this MapperFactory,
provided when this MapperFactory was constructed. |
|
|
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. |
|
|
lookupMapper(MapperKey mapperKey)
Get the Mapper (if any) which has been associated with the given MapperKey. |
|
Mapper<Object,Object> |
lookupMapper(MapperKey mapperKey,
MappingContext context)
Searches for a Mapper which is capable of mapping the classes identified by the provided MapperKey instance |
|
|
lookupObjectFactory(Type<T> targetType)
Return the object factory (if any) which has been registered for the given type. |
|
|
lookupObjectFactory(Type<T> type,
MappingContext context)
|
|
Set<ClassMap<Object,Object>> |
lookupUsedClassMap(MapperKey mapperKey)
Lookup the class map hierarchy used for the mapping defined by the specified MapperKey, if any exists |
|
protected
|
register(Type<S> sourceType,
Type<D> destinationType,
boolean isAutoGenerated)
Registers that a mapping exists from the specified source type to the specified destination type |
|
|
registerClassMap(ClassMap<A,B> classMap)
Registers the given ClassMap instance with the factory; it will be used to configure an appropriate mapping. |
|
|
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... mappers)
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. |
|
|
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. |
|
|
registerObjectFactory(ObjectFactory<D> objectFactory,
Type<D> destinationType)
Register the given ObjectFactory with the MapperFactory; it will be used when constructing new instances of the specified targetType. |
|
|
registerObjectFactory(ObjectFactory<T> objectFactory,
Class<T> targetClass)
Register the given ObjectFactory with the MapperFactory; it will be used when constructing new instances of the specified targetType. |
|
protected Type<?> |
resolveConcreteType(Type<?> type,
Type<?> originalType)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected DefaultMapperFactory(DefaultMapperFactory.MapperFactoryBuilder<?,?> builder)
builder - | Method Detail |
|---|
protected void addClassMapBuilderFactory(ClassMapBuilderFactory factory)
factory -
protected UnenhanceStrategy buildUnenhanceStrategy(UnenhanceStrategy unenhanceStrategy,
SuperTypeResolverStrategy superTypeStrategy)
unenhanceStrategy - superTypeStrategy - true if the passed UnenhanceStrategy should take full
responsibility for un-enhancement; false if the default
behavior should be applied as a fail-safe after consulting the
passed strategy.
protected MapperFacade buildMapperFacade(MappingContextFactory contextFactory,
UnenhanceStrategy unenhanceStrategy)
contextFactory - unenhanceStrategy -
public <A,B> Mapper<A,B> lookupMapper(MapperKey mapperKey)
MapperFactory
lookupMapper in interface MapperFactorymapperKey - the MapperKey for which to look up an associated Mapper
mapperKey;
public Mapper<Object,Object> lookupMapper(MapperKey mapperKey,
MappingContext context)
mapperKey - context -
public boolean existsRegisteredMapper(Type<?> sourceType,
Type<?> destinationType,
boolean includeAutoGeneratedMappers)
MapperFactory
existsRegisteredMapper in interface MapperFactorysourceType - the source typedestinationType - the destination typeincludeAutoGeneratedMappers - specifies whether an auto-generated mapper for the given
source and destination type should be considered
protected <A,B> Mapper<A,B> getRegisteredMapper(MapperKey mapperKey)
mapperKey -
protected <A,B> Mapper<A,B> getRegisteredMapper(Type<A> typeA,
Type<B> typeB,
boolean includeAutoGeneratedMappers)
typeA - typeB - includeAutoGeneratedMappers - whether auto-generated mappers should be included in the
lookup
public MapperFacade getMapperFacade()
getMapperFacade in interface MapperFactory
public <D> void registerObjectFactory(ObjectFactory<D> objectFactory,
Type<D> destinationType)
MapperFactory
registerObjectFactory in interface MapperFactoryobjectFactory - the object factory to registerdestinationType - the type which is generated by the given object factory@Deprecated public void registerMappingHint(MappingHint... hints)
registerMappingHint in interface MapperFactorypublic void registerDefaultFieldMapper(DefaultFieldMapper... mappers)
MapperFactory
registerDefaultFieldMapper in interface MapperFactorymappers - one or more DefaultFieldMapper instances to register
public void registerConcreteType(Type<?> abstractType,
Type<?> concreteType)
MapperFactory
registerConcreteType in interface MapperFactoryabstractType - the type of the abstract class or interfaceconcreteType - the concrete type to instantiate
public void registerConcreteType(Class<?> abstractType,
Class<?> concreteType)
MapperFactory
registerConcreteType in interface MapperFactoryabstractType - the abstract class or interfaceconcreteType - the concrete class to instantiatepublic <T> ObjectFactory<T> lookupObjectFactory(Type<T> targetType)
MapperFactory
lookupObjectFactory in interface MapperFactorytargetType - the type for which to lookup a registered ObjectFactory.
null if no ObjectFactory has been registered for the
given type.
public <T> ObjectFactory<T> lookupObjectFactory(Type<T> type,
MappingContext context)
type - context -
public <S,D> Type<? extends D> lookupConcreteDestinationType(Type<S> sourceType,
Type<D> destinationType,
MappingContext context)
lookupConcreteDestinationType in interface MapperFactory
protected Type<?> resolveConcreteType(Type<?> type,
Type<?> originalType)
type - originalType -
public <A,B> void registerClassMap(ClassMap<A,B> classMap)
MapperFactory
registerClassMap in interface MapperFactoryclassMap - the ClassMap instance to registerpublic <A,B> void registerClassMap(ClassMapBuilder<A,B> builder)
MapperFactory
registerClassMap in interface MapperFactorybuilder - the ClassMapBuilder to registerpublic void build()
MapperFactory
build in interface MapperFactorypublic Set<ClassMap<Object,Object>> lookupUsedClassMap(MapperKey mapperKey)
MapperFactory
lookupUsedClassMap in interface MapperFactorymapperKey - the mapper key defining the mapping to resolve
protected <S,D> void register(Type<S> sourceType,
Type<D> destinationType,
boolean isAutoGenerated)
sourceType - destinationType - public <A,B> ClassMap<A,B> getClassMap(MapperKey mapperKey)
MapperFactory
getClassMap in interface MapperFactorymapperKey - the MapperKey which should be used to look up an associated
ClassMap
null if no instance has been associated with this
MapperKey instance.public Set<Type<? extends Object>> lookupMappedClasses(Type<?> type)
MapperFactory
lookupMappedClasses in interface MapperFactorytype - the type for which to look up mapped types
public ConverterFactory getConverterFactory()
MapperFactory
getConverterFactory in interface MapperFactory
public <T> void registerObjectFactory(ObjectFactory<T> objectFactory,
Class<T> targetClass)
MapperFactory
registerObjectFactory in interface MapperFactoryobjectFactory - the object factory to registerprotected ClassMapBuilderFactory getClassMapBuilderFactory()
public <A,B> ClassMapBuilder<A,B> classMap(Type<A> aType,
Type<B> bType)
MapperFactoryregisterClassMap method.
classMap in interface MapperFactoryaType - the Type instance representing the "A" side of the mappingbType - the Type instance representing the "B" side of the mapping
public <A,B> ClassMapBuilder<A,B> classMap(Class<A> aType,
Type<B> bType)
MapperFactoryregisterClassMap method.
classMap in interface MapperFactoryaType - the Class instance representing the "A" side of the mappingbType - the Type instance representing the "B" side of the mapping
public <A,B> ClassMapBuilder<A,B> classMap(Type<A> aType,
Class<B> bType)
MapperFactoryregisterClassMap method.
classMap in interface MapperFactoryaType - the Type instance representing the "A" side of the mappingbType - the Class instance representing the "B" side of the mapping
public <A,B> ClassMapBuilder<A,B> classMap(Class<A> aType,
Class<B> bType)
MapperFactoryregisterClassMap method.
classMap in interface MapperFactoryaType - the Class instance representing the "A" side of the mappingbType - the Class instance representing the "B" side of the mapping
public <A,B> void registerMapper(Mapper<A,B> mapper)
MapperFactory
registerMapper in interface MapperFactorymapper - the mapper to register
public <S,D> BoundMapperFacade<S,D> getMapperFacade(Type<S> sourceType,
Type<D> destinationType)
MapperFactory
getMapperFacade in interface MapperFactorysourceType - the 'A' type for the returned DedicatedMapperFacadedestinationType - the 'B' type for the returned DedicatedMapperFacade
public <S,D> BoundMapperFacade<S,D> getMapperFacade(Type<S> sourceType,
Type<D> destinationType,
boolean containsCycles)
MapperFactoryfalse is provided for the 'containsCycles' parameter,
an optimized mapper instance will be provided.
getMapperFacade in interface MapperFactorysourceType - the 'A' type for the returned DedicatedMapperFacadedestinationType - the 'B' type for the returned DedicatedMapperFacadecontainsCycles - 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.
public <A,B> BoundMapperFacade<A,B> getMapperFacade(Class<A> aType,
Class<B> bType)
MapperFactory
getMapperFacade in interface MapperFactoryaType - the 'A' type for the returned DedicatedMapperFacadebType - the 'B' type for the returned DedicatedMapperFacade
public <A,B> BoundMapperFacade<A,B> getMapperFacade(Class<A> aType,
Class<B> bType,
boolean containsCycles)
MapperFactoryfalse is provided for the 'containsCycles' parameter,
an optimized mapper instance will be provided.
getMapperFacade in interface MapperFactoryaType - the 'A' type for the returned DedicatedMapperFacadebType - the 'B' type for the returned DedicatedMapperFacadecontainsCycles - 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.
public UnenhanceStrategy getUserUnenhanceStrategy()
MapperFactoryUnenhanceStrategy associated with this MapperFactory,
provided when this MapperFactory was constructed.
getUserUnenhanceStrategy in interface MapperFactoryUnenhanceStrategy associated with this MapperFactory.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||