org.elkoserver.foundation.json
Class StaticTypeResolver
java.lang.Object
org.elkoserver.foundation.json.StaticTypeResolver
- All Implemented Interfaces:
- TypeResolver
public class StaticTypeResolver
- extends Object
- implements TypeResolver
A simple type resolver that tries to resolve JSON type tags from statically
available class information rather than from a lookup table. It looks, in
the class (and its superclasses) for which it is trying to resolve a type
name, for a static method with the signature:
Class jsonClass(String typeName);
which it will then invoke to do the resolution. If it fails to find such a
method, it will default to assuming that the goal class is itself the proper
result.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
theStaticTypeResolver
public static final StaticTypeResolver theStaticTypeResolver
- The singleton instance of this resolver.
resolveType
public Class resolveType(Class baseType,
String typeName)
- Resolve a JSON type tag. This is done by looking for a method named
'jsonClass' in the class 'baseType' (or one of its superclasses), then
invoking this method to perform the resolution. If such a method
doesn't exist, then assume that the class 'baseType' itself is the right
answer.
- Specified by:
resolveType in interface TypeResolver
- Parameters:
baseType - The base class to which the type name should resolve
(and from which a 'jsonClass' method will be sought).typeName - The JSON type tag string whose resolution is sought.
- Returns:
- a suitable class for the name 'typeName' that can be assigned to
a parameter of class 'baseType'.