public class TypeResolverRegistry extends Object
Constructor and Description |
---|
TypeResolverRegistry(ITypeResolver defaultResolver)
|
Modifier and Type | Method and Description |
---|---|
<T> ITypeResolver
|
getResolverForType(Class<T> type)
Gets the ITypeResolver that was registered for the specified
type.
|
<T> void |
registerTypeResolver(Class<T> resolvedType,
ITypeResolver resolver)
Registers the given ITypeResolver for the given class.
|
void |
setDefaultResolver(ITypeResolver defaultResolver)
Sets the default ITypeResolver that is used for classes that have
no ITypeResolver registered.
|
public TypeResolverRegistry(ITypeResolver defaultResolver)
public <T> void registerTypeResolver(Class<T> resolvedType, ITypeResolver resolver)
Registers the given ITypeResolver for the given class. The registered ITypeResolver's reolve().method will only be called with objects of the specified class.
Note that each type can only be resolved by ONE ITypeResolver implementation. Multiple calls to registerTypeResolver() with the same resolvedType parameter will override earlier calls.
T
- the type resolved by the ITypeResolver.resolvedType
- the class whose objects are to be passed to the
given ITypeResolver.
resolver
- the resolver to resolve objects of the given type.public <T> ITypeResolver getResolverForType(Class<T> type)
T
- the type resolved by the ITypeResolver.type
- the class for which to find the ITypeResolver.public void setDefaultResolver(ITypeResolver defaultResolver)
defaultResolver
- the resolver to use as default.Copyright © 2016. All rights reserved.