public abstract class GenericMetadataSupport
extends java.lang.Object
The main idea of this code is to create a Map that will help to resolve return types. In order to actually work with nested generics, this map will have to be passed along new instances as a type context.
Hence :
inferFrom(Type) method from a real
Class or from a ParameterizedType, other types are not yet supported.resolveGenericReturnType(Method).For now this code support the following kind of generic declarations :
interface GenericsNest<K extends Comparable<K> & Cloneable> extends Map<K, Set<Number>> {
Set<Number> remove(Object key); // override with fixed ParameterizedType
List<? super Integer> returning_wildcard_with_class_lower_bound();
List<? super K> returning_wildcard_with_typeVar_lower_bound();
List<? extends K> returning_wildcard_with_typeVar_upper_bound();
K returningK();
<O extends K> List<O> paramType_with_type_params();
<S, T extends S> T two_type_params();
<O extends K> O typeVar_with_type_params();
Number returningNonGeneric();
}
| Modifier and Type | Class and Description |
|---|---|
static interface |
GenericMetadataSupport.BoundedType
Type representing bounds of a type
|
static class |
GenericMetadataSupport.TypeVarBoundedType
Type representing bounds of a type variable, allows to keep all bounds information.
|
static class |
GenericMetadataSupport.WildCardBoundedType
Type representing bounds of a wildcard, allows to keep all bounds information.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> |
contextualActualTypeParameters
Represents actual type variables resolved for current class.
|
| Constructor and Description |
|---|
GenericMetadataSupport() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> |
actualTypeArguments() |
java.util.List<java.lang.reflect.Type> |
extraInterfaces() |
protected java.lang.reflect.Type |
getActualTypeArgumentFor(java.lang.reflect.TypeVariable typeParameter) |
boolean |
hasRawExtraInterfaces() |
static GenericMetadataSupport |
inferFrom(java.lang.reflect.Type type)
Create an new instance of
GenericMetadataSupport inferred from a Type. |
java.lang.Class<?>[] |
rawExtraInterfaces() |
abstract java.lang.Class<?> |
rawType() |
protected void |
registerTypeParametersOn(java.lang.reflect.TypeVariable[] typeParameters) |
protected void |
registerTypeVariablesOn(java.lang.reflect.Type classType) |
GenericMetadataSupport |
resolveGenericReturnType(java.lang.reflect.Method method)
Resolve current method generic return type to a
GenericMetadataSupport. |
protected java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> contextualActualTypeParameters
protected void registerTypeVariablesOn(java.lang.reflect.Type classType)
protected void registerTypeParametersOn(java.lang.reflect.TypeVariable[] typeParameters)
public abstract java.lang.Class<?> rawType()
public java.util.List<java.lang.reflect.Type> extraInterfaces()
public java.lang.Class<?>[] rawExtraInterfaces()
extraInterfaces() if relevant.public boolean hasRawExtraInterfaces()
extraInterfaces() if relevant.public java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> actualTypeArguments()
GenericMetadataSupport instance.protected java.lang.reflect.Type getActualTypeArgumentFor(java.lang.reflect.TypeVariable typeParameter)
public GenericMetadataSupport resolveGenericReturnType(java.lang.reflect.Method method)
GenericMetadataSupport.method - Method to resolve the return type.GenericMetadataSupport representing this generic return type.public static GenericMetadataSupport inferFrom(java.lang.reflect.Type type)
GenericMetadataSupport inferred from a Type.
At the moment type can only be a Class or a ParameterizedType, otherwise
it'll throw a MockitoException.
type - The class from which the GenericMetadataSupport should be built.GenericMetadataSupport.MockitoException - Raised if type is not a Class or a ParameterizedType.