Interface ClassMapper
- All Known Implementing Classes:
DefaultClassMapper
public interface ClassMapper
Maps names or classes to classes.
- Author:
- harald
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ClassMappedListener listener) Adds a class mapped listener.static ClassMapperCreates a class mapper for a given mapped service.
The mapper maintains a map of implementation classes to other classes (usually interfaces).Class<?> Gets the default class.getMap()Gets a copy of the names map.Class<?> Maps a class or interface to another class or interface.Class<?> Maps a class or interface to another class or interface by its name.Class<?> mapLenient(Class<?> clazz) Maps a class or interface to another class or interface.
If there is no mapping forclazzits superclasses are tried.Class<?> mapLenient(String name) Maps a name to a class.voidRemoves all class mapped listeners.booleanremoveListener(ClassMappedListener listener) Removes a class mapped listener.voidsetDefaultClass(Class<?> defaultClass) Sets the default class.
If there is no matching class, the mapper returns this class.
-
Method Details
-
create
Creates a class mapper for a given mapped service.
The mapper maintains a map of implementation classes to other classes (usually interfaces).- Parameters:
name- the mapper's namemappedClass- class of the mapped service- Returns:
- the classmapper
- See Also:
-
map
Maps a class or interface to another class or interface.- Parameters:
clazz- the class to map- Returns:
- the mapped class, never null
- Throws:
ClassNotFoundException- if there is no mapping
-
map
Maps a class or interface to another class or interface by its name.- Parameters:
name- the name or basename of the class to map- Returns:
- the mapped class, never null
- Throws:
ClassNotFoundException- if there is no mapping
-
mapLenient
Maps a class or interface to another class or interface.
If there is no mapping forclazzits superclasses are tried. Ifclazzis an interface, all its super interfaces are tried.Notice: for classes their interfaces will be ignored.
- Parameters:
clazz- the class to map- Returns:
- the mapped class, never null
- Throws:
ClassNotFoundException- if there is no mapping
-
mapLenient
Maps a name to a class.- Parameters:
name- the name to map- Returns:
- the mapped class, never null
- Throws:
ClassNotFoundException- if there is no mapping
-
getDefaultClass
-
setDefaultClass
Sets the default class.
If there is no matching class, the mapper returns this class.- Parameters:
defaultClass- the default class
-
getMap
-
addListener
Adds a class mapped listener.- Parameters:
listener- invoked whenever a class is mapped the first time
-
removeListener
Removes a class mapped listener.- Parameters:
listener- the listener- Returns:
- true if removed, false if no such listener
-
removeAllListeners
void removeAllListeners()Removes all class mapped listeners.
-