public class MappedClassResolver extends Object implements ClassResolver
ClassResolver
interface that uses an internal Map
to define specific
mappings. If no mapping is found for the requested
type the default strategy
Class.forName(String)
is used.Modifier and Type | Field and Description |
---|---|
private Map<String,Class<?>> |
name2classMap |
CLASS_FOR_NAME_RESOLVER
Constructor and Description |
---|
MappedClassResolver()
The constructor.
|
MappedClassResolver(MapFactory<? extends Map> mapFactory)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassMapping(Class<?> type)
This method adds a mapping for the given
type using the simple-name . |
void |
addClassMapping(String name,
Class<?> type)
This method adds a mapping for the given
type using the given name . |
Class<?> |
resolveClass(String name)
This method resolves the class with the given
name . |
public MappedClassResolver()
public MappedClassResolver(MapFactory<? extends Map> mapFactory)
mapFactory
- the factory used to create the underlying Map
.public void addClassMapping(Class<?> type)
type
using the simple-name
.type
- is the type to add.public void addClassMapping(String name, Class<?> type)
type
using the given name
.name
- is the name under which the class is mapped
.type
- is the mapped class.public Class<?> resolveClass(String name)
ClassResolver
name
. In addition to a ClassLoader
this method may
also find types via a logical alias name. name
can be the physical (fully qualified) classname (e.g. org.foo.BlobImpl
) but this may also
be a logical name depending on the implementation of this interface (e.g. Blob
may point to the same type).resolveClass
in interface ClassResolver
name
- is the logical or physical name of the requested type.name
.Copyright © 2001–2016 mmm-Team. All rights reserved.