@ComponentSpecification public interface GenericTypeFactory
GenericTypes.| Modifier and Type | Method and Description |
|---|---|
<T> GenericType<T> |
createGenericType(Class<T> type)
This method creates the
GenericType representing the given type. |
GenericType<?> |
createGenericType(Type type)
This method creates the
GenericType representing the given type. |
GenericType<?> |
createGenericType(Type type,
Class<?> definingType)
This method creates the
GenericType representing the given type in the context of
the given definingType. |
GenericType<?> |
createGenericType(Type type,
GenericType<?> definingType)
This method creates the
GenericType representing the given type in the context of
the given definingType. |
<T> GenericType<T> createGenericType(Class<T> type)
GenericType representing the given type. type, lower bound and
upper bound of the returned GenericType will all be
identical to the given type. Type where the given type was
defined you should use
createGenericType(Type, GenericType) instead to get a more precise result. T - is the generic type of the Class to convert.type - is the Type to represent.GenericType.GenericType<?> createGenericType(Type type)
GenericType representing the given type. type is a Class, the methods behaves like
createGenericType(Class). Type where the given type was defined (e.g. the Class where
you retrieved the given type from as parameter, return-type or field-type) you should use
createGenericType(Type, GenericType) instead to get a more precise result.type - is the Type to represent.GenericType.GenericType<?> createGenericType(Type type, GenericType<?> definingType)
GenericType representing the given type in the context of
the given definingType. Now if you ask your self why all this instead of just usingReflectionUtilutil =ReflectionUtilImpl.getInstance(); Class<?> myClass = getSomeClass(); GenericType definingType = util.createGenericType(myClass);MethodmyMethod = findSomeMethod(myClass); Type returnType = myMethod.getGenericReturnType(); GenericType type = util.createGenericType(returnType, definingType); Class<?> returnClass = type.GenericType.getRetrievalClass();
myMethod.getReturnType() ? Read the javadoc
of GenericType to get the answer. mmm-util-pojo which allows to use this features at a higher level and
therefore much easier.type - is the Type to represent.definingType - is the GenericType where the given type is defined in. It is
needed to resolve TypeVariables.GenericType.createGenericType(Type, Class)GenericType<?> createGenericType(Type type, Class<?> definingType)
GenericType representing the given type in the context of
the given definingType. createGenericType(type,
createGenericType(definingType))type - is the Type to represent.definingType - is the Class where the given type is defined in. It is needed to
resolve TypeVariables.GenericType.Copyright © 2001–2015 mmm-Team. All rights reserved.