@Beta public final class TypeResolver extends Object
where(java.lang.reflect.Type, java.lang.reflect.Type)and types are resolved using
Note that usually type mappings are already implied by the static type hierarchy (for example,
E type variable declared by class
List naturally maps to
the context of
class MyStringList implements List<String>. In such case, prefer to use
TypeToken.resolveType(java.lang.reflect.Type) since it's simpler and more type safe. This class should only be
used when the type mapping isn't implied by the static type hierarchy, but provided through other
means such as an annotation or external configuration file.
|Constructor and Description|
|Modifier and Type||Method and Description|
Resolves all type variables in
Returns a new
public TypeResolver where(Type formal, Type actual)
TypeResolverwith type variables in
formalmapping to types in
For example, if
formal is a
TypeVariable T, and
new TypeResolver().where(formal, actual) will
ParameterizedType List<T> to
Map<T, Something> to
Map<String, Something> etc. Similarly,
actual can be
Map<K, V> and
respectively, or they can be
String respectively, or even any
arbitrary combination thereof.
formal- The type whose type variables or itself is mapped to other type(s). It's almost always a bug if
formalisn't a type variable and contains no type variable. Make sure you are passing the two parameters in the right order.
actual- The type that the formal type variable(s) are mapped to. It can be or contain yet other type variables, in which case these type variables will be further resolved if corresponding mappings exist in the current
Copyright © 2010-2016. All Rights Reserved.